msgraph-sdk-java icon indicating copy to clipboard operation
msgraph-sdk-java copied to clipboard

How to make com.microsoft.graph.logger.DefaultLogger log to a file

Open lchen016 opened this issue 3 years ago • 0 comments

Our software, which is integrated with Microsoft Graph Java SDK, uses log4j2 as the logging framework. When creating the GraphServiceClient instance, we pass in a DefaultLogger instance with a level that can be configured (ERROR or DEBUG).

Expected behavior

Microsoft Graph Java SDK DefaultLogger can log into the same log file as specified by our software with the logger level we expected.

I want to know if it is possible to redirect the loggers from Microsoft Graph Java SDK DefaultLogger to log4j2 framework, and how to, if possible.

Actual behavior

the Microsoft Graph Java SDK logs are not logged into the log file, rather they are calculated in a buffer array, which caused memory to increase and throw the "Requested array size exceeds VM limit" exception.

Steps to reproduce the behavior

DefaultLogger logger = new DefaultLogger(); logger.setLoggingLevel(LoggerLevel.DEBUG); GraphServiceClient .builder() .httpClient(graphHttpClient) .logger(logger) .buildClient();

lchen016 avatar Sep 12 '22 13:09 lchen016