Skip to content
This repository was archived by the owner on Feb 1, 2024. It is now read-only.
This repository was archived by the owner on Feb 1, 2024. It is now read-only.

How to use it #74

@mareksloser

Description

@mareksloser

Hello,

thank you for this code.

Could you help me? How i can use this handler?

RotatingFileHandler - handler working well, i have new line every time in main-DATE.log
But how to use AppInsights_Handler? I dont know if i miss someting. I have no data in Azure appInsight, no errors nothing happend.

protected static function configureInstance(): void {
	$dir = dirname(__DIR__) . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . 'log';

	if( ! file_exists( $dir ) && ! mkdir( $dir, 0777, true ) && ! is_dir( $dir ) ) {
		throw new \RuntimeException( sprintf( 'Directory "%s" was not created', $dir ) );
	}

	$logger = new Logger('Wordpress');

	$client = new ClientFactory(
		self::$instrumentation_key,
		AppInsightsPHP\Client\Configuration::createDefault(),
		new Psr16Cache(new ArrayAdapter()),
		$logger
	);

	$logger->pushHandler(new AppInsightsDependencyHandler($client->create()));
	$logger->pushHandler(new RotatingFileHandler($dir . DIRECTORY_SEPARATOR . 'main.log', 5));

	self::$instance = $logger;
}

Thank you

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions