question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow constomizing the log format produced by `Logging{Service,Client}`

See original GitHub issue

The logs produced by LoggingService and LoggingClient are human-readable. However, this non-structured text is not good when users want to store the log file to Elastic Search or other key-value storage. We can give an extension API to users to customize the output format. For example:

interface LogFormat {
    static LogFormat ofText() {
        // return a log message formatted by the default formatter. 
    }

    static LogFormat ofJson() {
        // return a log message serialized to JSON format
    }

    String format(RequestLog log, LogSanitizers sanitizers);
}

class LogSanitizers {
    BiFunction<? super RequestContext, ? super RequestHeaders, ? extends @Nullable Object> requestHeadersSanitizer;
    BiFunction<? super RequestContext, Object, ? extends @Nullable Object> requestContentSanitizer;
    ...
}

LoggingService.builder()
              // Customize the log message format using LogFormat
              .format(LogFormat.ofJson())

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:15 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
ikhooncommented, Apr 15, 2022

hasInterestedFlags(flags, RequestLogProperty.REQUEST_LENGTH) must be the same with RequestLog.isAvailable(RequestLogProperty.REQUEST_LENGTH). By the way, flags is a volatile value. So it is bad to access it repeatedly. How about adding an API that returns all available RequestLogPropertys?

interface RequestLogAccess {
    Set<RequestLogProperty> availableProperties();
}
1reaction
ikhooncommented, Apr 8, 2022

Sure ❤️

Read more comments on GitHub >

github_iconTop Results From Across the Web

Enabling logging from certain AWS services
Explains the permissions necessary for sending logs from some AWS services to CloudWatch Logs, Amazon S3, or Kinesis Data Firehose.
Read more >
Customizing the HTTP access log - Oracle Help Center
You can customize the format of the default HTTP access log. By default, WebLogic Server keeps a log of all HTTP transactions in...
Read more >
Logging Cookbook — Python 3.11.1 documentation
Let's say you want to log to console and file with different message formats and in differing circumstances. Say you want to log...
Read more >
Console log formatting - .NET - Microsoft Learn
Previously, the ConsoleLoggerFormat enum allowed for selecting the desired log format, either human readable which was the Default ...
Read more >
Customizing the Log Format - OpenLiteSpeed
Customizing Log Format in OpenLiteSpeed is possible, and something you may wish to do during the troubleshooting process.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found