2

Log4j not logging when I use Tomcat's Windows Service, but working with startup.bat

Java Options for Tomcat Window Service

-Dcatalina.home=D:\CSA\apache-tomcat-7.0.62
-Dcatalina.base=D:\CSA\apache-tomcat-7.0.62    
-Djava.endorsed.dirs=D:\CSA\apache-tomcat-7.0.62\endorsed    
-Djava.io.tmpdir=D:\CSA\apache-tomcat-7.0.62\temp    
-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager    
-Djava.util.logging.config.file=D:\CSA\apache-tomcat-7.0.62\conf\logging.properties    
-Djava.security.policy=D:\CSA\apache-tomcat-7.0.62\conf\catalina.policy    
-Dlog4j.debug

The difference in Service and Startup.bat log is

log4j: setFile ended

Debug with Window Service gave following output

log4j: Trying to find [log4j.xml] using context classloader WebappClassLoader
  context: /CSAUpload
  delegate: false
  repositories:
    /WEB-INF/classes/
----------> Parent Classloader:
org.apache.catalina.loader.StandardClassLoader@6ed8b42
.
log4j: Using URL [file:/D:/CSA/apache-tomcat-7.0.62/webapps/CSAUpload/WEB-INF/classes/log4j.xml] for automatic log4j configuration.
log4j: Preferred configurator class: org.apache.log4j.xml.DOMConfigurator
log4j: System property is :null
log4j: Standard DocumentBuilderFactory search succeded.
log4j: DocumentBuilderFactory is: org.apache.xerces.jaxp.DocumentBuilderFactoryImpl
log4j: debug attribute= "true".
log4j: Threshold ="null".
log4j: Level value for root is  [INFO].
log4j: root level set to INFO
log4j: Class name: [org.apache.log4j.RollingFileAppender]
log4j: Setting property [append] to [true].
log4j: Setting property [maxFileSize] to [10KB].
log4j: Setting property [maxBackupIndex] to [5].
log4j: Setting property [file] to [D:/CSA/CSALog/upload.log].
log4j: Parsing layout of class: "org.apache.log4j.PatternLayout"
log4j: Setting property [conversionPattern] to [%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n].
log4j: setFile called: D:/CSA/CSALog/upload.log, true
log4j: Adding appender named [file] to category [root].

Debug with startup.bat gave following output

log4j: Trying to find [log4j.xml] using context classloader WebappClassLoader
  context: /CSAUpload
  delegate: false
  repositories:
    /WEB-INF/classes/
----------> Parent Classloader:
org.apache.catalina.loader.StandardClassLoader@151c2b4
.
log4j: Using URL [file:/D:/CSA/apache-tomcat-7.0.62/webapps/CSAUpload/WEB-INF/classes/log4j.xml] for automatic log4j configuration.
log4j: Preferred configurator class: org.apache.log4j.xml.DOMConfigurator
log4j: System property is :null
log4j: Standard DocumentBuilderFactory search succeded.
log4j: DocumentBuilderFactory is: org.apache.xerces.jaxp.DocumentBuilderFactoryImpl
log4j: debug attribute= "true".
log4j: Threshold ="null".
log4j: Level value for root is  [INFO].
log4j: root level set to INFO
log4j: Class name: [org.apache.log4j.RollingFileAppender]
log4j: Setting property [append] to [true].
log4j: Setting property [maxFileSize] to [10KB].
log4j: Setting property [maxBackupIndex] to [5].
log4j: Setting property [file] to [D:/CSA/CSALog/upload.log].
log4j: Parsing layout of class: "org.apache.log4j.PatternLayout"
log4j: Setting property [conversionPattern] to [%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n].
log4j: setFile called: D:/CSA/CSALog/upload.log, true
log4j: setFile ended
log4j: Adding appender named [file] to category [root].

log4j.xml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration debug="true"
    xmlns:log4j='http://jakarta.apache.org/log4j/'> 
    <appender name="file" class="org.apache.log4j.RollingFileAppender">
       <param name="append" value="true" />
       <param name="maxFileSize" value="10KB" />
       <param name="maxBackupIndex" value="5" />
       <!-- For Tomcat -->
       <param name="file" value="D:/CSA/CSALog/upload.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> 
    <root>
        <level value="INFO" />
        <appender-ref ref="file" />
    </root> 
</log4j:configuration>

Please guide what could be the issue here...

user2870419
  • 43
  • 1
  • 6
  • http://stackoverflow.com/questions/1508711/tomcat-logging-while-running-as-a-windows-service – aravind Aug 06 '15 at 12:15
  • **Able to track the issue** - The issue is "Log on as" in Tomcat, authorized to a remote repository. And to write logs we need it mapped to "Local System Account". But now new issue arises how to map both ? – user2870419 Aug 06 '15 at 15:35

0 Answers0