Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Websphere with Logback logging to system out - formatting issue

I am using Logback in my application hosted on Websphere App Server. Logback is configured to log to System Out (and others are hesitant to change to a different file). The issue is that Websphere uses its own format for logging to System Out. Executing logger.debug("test") in my app yields:

[8/7/12 12:27:55:629 CDT] 0000003a SystemOut     O DEBUG com.myapp... test

where everything up to the "O" is added by Websphere. The rest is from Logback

I have set up Logback to use the following pattern: %-5level %logger{36} - %msg%n so that I don't repeat timestamp and thread info which Websphere does on its own, but I am still annoyed that I can't fully customize the logging to System Out from within Logback.

I don't know a whole lot about logging best practices. Before, I have logged to separate files by web app, but for this project, I was told the System Out files are monitored by a third party and I should not change from using System Out. Is there any way to get around my issue given these requirements and tell Websphere not to mess with my System Out logging, or is the only solution to start logging to a different file? Thanks!

like image 584
stephen.hanson Avatar asked Aug 07 '12 21:08

stephen.hanson


People also ask

How to check logs in WebSphere Application Server?

WebSphere Application Server application log files can be found in the logs folder for each profile in the cell; for example, $WAS_HOME/profiles/<profile_name>/logs. There is a folder for each server in the logs directory. This location is where the JVM stdout and stderr logs (SystemOut. log and SystemErr.

How to enable traces in WebSphere Application Server?

Enabling diagnostic traceIn the WebSphere Application Server administrative console, click Troubleshooting > Logs and Trace > server-name > Diagnostic Trace > Change Log Detail Levels, where server-name is the name of the application server on which you want to enable trace.

What is native logs in WebSphere?

Process logs WebSphere Application Server processes contain two output streams that are accessible to native code running in the process. These streams are the stdout and stderr streams. Native code, including Java virtual machines (JVM), might write data to these process streams. In addition, JVM provided System.


2 Answers

Your logback is configured to write messages to System.out. However, everything that is written to System.out is redirected by WebSphere and written to the SystemOut.log file with the same format as log messages produced by WebSphere, but with a severity indicator "O". It is not possible to change that.

Note that it is likely that the people who told you to use SystemOut.log actually meant that you should ensure that logging is done using WebSphere's log system so that messages are written with the correct category and severity and that log levels can be changed at runtime. Since WebSphere's log system is build on java.util.logging you should probably just replace logback by slf4j-jdk14 to satisfy their requirement.

like image 163
Andreas Veithen Avatar answered Sep 23 '22 15:09

Andreas Veithen


I don't think you're going to be able to change the format. And if you could, it might break the current monitoring anyway.

I wonder if anyone would mind if you log to two loggers at the same time, SystemOut for the existing monitoring, and your own for a more readable format.

like image 31
dbreaux Avatar answered Sep 23 '22 15:09

dbreaux