Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tip: Logging via another logging system #44

Open
robshep opened this issue May 10, 2018 · 0 comments
Open

Tip: Logging via another logging system #44

robshep opened this issue May 10, 2018 · 0 comments

Comments

@robshep
Copy link

robshep commented May 10, 2018

Hi,

I didn't want to setup a new logfile destination - I just wanted to log via the application's main logging subsystem.

I have quickly hacked together a bridge that logs via another logger that can be simply constructed to suit any other logging provider.

Code is here: https://gist.github.com/robshep/918c9b6eb95fd740f11891e3a2ebc9ad

The implementation that will be required can be seen in my local example:
LogbackAccessLogAdapter.java which is configured in the logback-access.xml

In my example, I log to my application's SLF4J logger using the RequestLog logger name, and I also set a filter for ignoring unwanted access log items.

The bridge itself (AccessLogToMainLogAppender.java) goes round-the-houses by using an hacked OutputStream, but that means I can continue using Pattern layout encoders etc for config simplicity.

Anyway, it might be useful to your users so feel free to point at the gist or copy it to a wiki or whatever you like.

Rob

@robshep robshep changed the title Tip: Logging via the main application Logback configuration Tip: Logging via another logging system May 10, 2018
@akkinoc akkinoc added this to the v2 milestone Sep 5, 2021
@akkinoc akkinoc removed this from the v2 milestone Oct 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants