-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
How to change the prefix of the console output log? #7018
Comments
The output format Jetty uses the format The The fact that it writes to That ubuntu script sets the So in conclusion, the filename, the location of the logs, and the format of the logs are all clues that tell us these logs are not from Jetty. Incidentally, the linked Also, Jetty 9.4.16 is subject to several security advisories, please do not use that version with a website that faces the public internet. |
Another thing to consider, have you configured your logging to capture all of the logging events from the other logging libraries and route them to log4j for logging? Common logging libraries (in order of most to least common):
If you use anything more than just raw Servlets (this includes JSP) you are subject to at least 2 or more of the above list. The most common way to address this is to use slf4j to route all of the logging library events to slf4j, and then the slf4j binding implementation (like log4j 1.x) to write the content to disk. Note: the fact that you report a If something is doing that for you, then you should ...
This behavior is probably something that the ubuntu folks have mangled into their custom |
Thank you for the extensive explanation!
I am on a Raspberry Pi. The fact that I linked a file relating to Ubuntu is concidental. I just googled the name of the author ("Philipp Meier") with some keywords.
Well, that's... one of the many problems I'll have to work on eventually.
I don't think so. I simply added the log4j api and core JARs, added a simple log4j2.xml that logs to console and started using
Also not sure. I have classes that extend HttpServlet and override doPost. Other than that I don't think there's much magic involved in the actual Java code that constitutes my program.
Seems reasonable to me, though. log4j pipes to console, System.out.println also writes to console, the console output is mangled to include the additional date/time/device/process info and that is finally written to the log file. <?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_3.dtd">
<Configure id="logging" class="org.eclipse.jetty.util.log.Log">
<New id="ServerLog" class="java.io.PrintStream">
<Arg>
<New class="org.eclipse.jetty.util.RolloverFileOutputStream">
<Arg><Property name="jetty.console-capture.dir" deprecated="jetty.logging.dir" default="./logs"/>/yyyy_mm_dd.jetty.log</Arg>
<Arg type="boolean"><Property name="jetty.console-capture.append" deprecated="jetty.logging.append" default="false"/></Arg>
<Arg type="int"><Property name="jetty.console-capture.retainDays" deprecated="jetty.logging.retainDays" default="90"/></Arg>
<Arg>
<Call class="java.util.TimeZone" name="getTimeZone">
<Arg><Property name="jetty.console-capture.timezone" deprecated="jetty.logging.timezone" default="GMT"/></Arg>
</Call>
</Arg>
<Get id="ServerLogName" name="datedFilename"/>
</New>
</Arg>
</New>
<Get name="rootLogger">
<Call name="info"><Arg>Console stderr/stdout captured to <Ref refid="ServerLogName"/></Arg></Call>
</Get>
<Call class="java.lang.System" name="setErr"><Arg><Ref refid="ServerLog"/></Arg></Call>
<Call class="java.lang.System" name="setOut"><Arg><Ref refid="ServerLog"/></Arg></Call>
</Configure> Is that what's doing this? Also, is the /etc/init.d/jetty9 file executed magically by Linux or must that file be called by another process? |
No the The fact that your log4j outputs only to Console means something else, outside of the JVM is creating those log files. |
This issue has been automatically marked as stale because it has been a |
While updating to Jetty 10, I had to dive a bit more deeply into the whole setup. I found out that we used rsyslog, and I'm pretty sure that that's responsible for the additional output. With Jetty 10, we're using the console-capture module now, and that does not show this additional output. Sorry for leaving this rotting for so long, but I just didn't get around to it earlier. |
Jetty 10 is now at End of Community Support. You should be using a supported version of Jetty now. If you still need |
Jetty version
According to the "Server" response header:
Jetty(9.4.16.v20190411)
Java version
Output of
java -version
:Question
How can I configure the way that console outputs from my Java code gets logged?
I have an inherited project where I don't know exactly how everything is configured. Jetty is started by
/etc/init.d/jetty9
, which looks like it's this script:https://www.apt-browse.org/browse/ubuntu/xenial/universe/all/jetty9/9.2.14-1/file/etc/init.d/jetty9
Logs are written to
/var/log/jetty9/jetty-console.log
and regularly archived.When I output something to the console using
System.out.println("Hello World");
, The log file getsOct 20 10:16:59 testpi jetty9[559]: Hello World
appended. I use log4j to handle my logging needs, so I don't need the additional, redundand information to be prepended to every line.There does not seem to be a console-capture.ini file.
find / | grep console-capture.ini
does not find anything.The text was updated successfully, but these errors were encountered: