Hello, I have some problem trying use log4j with System environment. This is my log4j.xml:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration PUBLIC "-//APACHE//DTD LOG4J 1.2//EN" "http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/xml/doc-files/log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<appender name="main" class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{HH:mm:ss} %5p [%-20c{1}] %m%n" />
</layout>
</appender>
<appender name="file" class="org.apache.log4j.RollingFileAppender">
<param name="append" value="false" />
<param name="maxFileSize" value="10MB" />
<param name="maxBackupIndex" value="10" />
<param name="file" value="${CATALINA_HOME}/logs/info.log" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n" />
</layout>
</appender>
<category name="org.jboss.logging">
<priority value="WARN" />
<appender-ref ref="main" />
</category>
<category name="org.jboss.weld">
<priority value="INFO" />
<appender-ref ref="main" />
</category>
<logger name="controller">
<level value="INFO" />
<appender-ref ref="main" />
<appender-ref ref="file" />
</logger >
</log4j:configuration>
I can see the logs on catalina.out, but is not creating the info.log.
Works fine on my computer, lol. Ty,
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Does ${CATALINA_HOME}/logs/info.log exist? You might need to create the file and allow Tomcat to write to it.
If catalina.out works fine, you can transfer its permissions to info.log:
sudo chmod --reference /path/to/catalina.out /path/to/info.log
sudo chown --reference /path/to/catalina.out /path/to/info.log
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.