My WAR is using a log4j FileAppender configured via a log4j.properties
file under the classes/
directory inside the WAR.
I have configured my log4j appender as such:
# Set the root logger to DEBUG. log4j.rootLogger=DEBUG # MonitorLog - used to log messages in the Monitor.log file. log4j.appender.MonitorAppender=org.apache.log4j.FileAppender log4j.appender.MonitorAppender.File=MonitorLog.log log4j.appender.MonitorAppender.layout=org.apache.log4j.PatternLayout log4j.appender.MonitorAppender.layout.ConversionPattern= %-4r [%t] %-5p %c %x - %m%n # Use the MonitorAppender to log all messages. log4j.logger.*=DEBUG,MonitorAppender
With this configuration I am trying to achieve the following:
MonitorLog.log
file to be located under Tomcat's logs/
directoryDoes this configuration achieve these items, and if not, what needs to change?
The file is named log4j. properties and is located in the $DGRAPH_HOME/dgraph-hdfs-agent/lib directory. The file defines the ROLLINGFILE appenders for the root logger and also sets the log level for the file. The level of the root logger is defined as INFO and attaches the ROLLINGFILE appender to it.
Apache Tomcat. Log4j may be used as the logging framework for Apache Tomcat. This support is implemented automatically by including the log4j-api, log4j-core, and log4j-appserver jars in the boot classpath.
Localhost Log : This is the log for all HTTP transactions between the client and the application server. The log file is named as, localhost_access_log. <date of log generation>. txt file. The default location and rotation policy for this log is the same as catalina.
If you know this WAR will only be deployed to a tomcat, you can take advantage of the system property catalina.base
, which represents the root of your tomcat base folder (there is also a cataline.home
, but they are often the same unless you have multiple tomcats running on the same machine and are sharing the server libs, but i digress).
So update as follows:
log4j.appender.MonitorAppender.File=${catalina.base}/logs/MonitorLog.log
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With