SMTPAppender in log4j.xml

I apologize if this is not the correct thread for this post.
I'm sure servlet developers can help me. Trying to get the org.apache.log4j.net.SMTPAppender class to work in a servlet environment. I have all jars required mail.jar, activation, and log4j-1.2.8.jar.
Here is my defined appender:
<appender name="SMTP" class="org.apache.log4j.net.SMTPAppender">
          <param name="To" value="[email protected]"/>
          <param name="From" value=" "/>
          <param name="Subject" value="Servlet Error"/>
          <param name="SMTPHost" value="mail.favroweb.com"/>
          <param name="BufferSize" value="100"/>
          <param name="Threshold" value="DEBUG"/>
          <layout class="org.apache.log4j.PatternLayout">
               <param name="ConversionPattern" value="=[%d{DATE}]%nServer hostname: %{server.hostname}%n%-5p %c{3} - %m%nThread name: %t%n"/>
          </layout>
     </appender>
and the logger:
<logger name="com.favroweb.resume.ResumeBuilder" additivity="false">
          <level value="DEBUG"/>
          <appender-ref ref="A2"/>
          <appender-ref ref="SMTP"/>
     </logger>
I plan on only logging ERROR and above from this Logger but am using DEBUG for testing.
A2 is a DailyRollingFileAppender and the class com.favroweb.resume.ResumeBuilder logs to this just fine.
If anyone has any working examples. Please advise.

That's pretty much what I have, except I'm using the old text configuration instead of the XML configuration. Only significant difference is that I have something in the "From" parameter.
It would help if you said what was wrong. My first guess would be that you can't send an e-mail without a From address, but besides that there's also the possibility that your server won't relay to your To address and other similar problems. SMTPAppender works for me but I'm just sending to an address in the same domain so I don't have any relaying or authentication issues.

Similar Messages

  • How to send a mail using SMTPAppender in Log4j..?

    Hello friends,
    I'm new to this forum.
    I'm trying to send mail using SMTPAppender.
    I am getting this error..
    javax.xml.parsers.FactoryConfigurationError: Provider for javax.xml.parsers.DocumentBuilderFactory cannot be found
    at javax.xml.parsers.DocumentBuilderFactory.newInstance(Unknown Source)
    at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:772)
    at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:696)
    at org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConverter.java:471)
    at org.apache.log4j.LogManager.<clinit>(LogManager.java:125)
    at org.apache.log4j.Logger.getLogger(Logger.java:105)
    at com.honeywell.logging.Log.<clinit>(Log.java:36)
    Exception in thread "main"
    Here is the code...
    Log.java
    package com.something.log;
    import org.apache.log4j.Logger;
    import org.apache.log4j.LogManager;
    import javax.mail.*;
    import javax.mail.internet.*;
    import org.apache.log4j.helpers.Loader;
    import org.apache.log4j.xml.DOMConfigurator;
    import java.net.URL;
    import java.util.*;
    import javax.mail.Message;
    import org.apache.log4j.PatternLayout;
    import org.apache.log4j.net.SMTPAppender;
    public class Main {
    * @param args the command line arguments
    private static final Logger lg=Logger.getLogger("com.something.log.Main");
    public static void main(String[] args) {
    URL url = Loader.getResource("log4j.xml");
                   DOMConfigurator.configure(url);
              // create email appender
         SMTPAppender smtpAppender = new SMTPAppender();
         smtpAppender.setTo("[email protected]");
         smtpAppender.setFrom("[email protected]");
         smtpAppender.setSMTPHost("smtp.something.com");
         smtpAppender.setSubject("Testing Email");
         smtpAppender.setLocationInfo(false);
         smtpAppender.setLayout(new PatternLayout("%d{ABSOLUTE} %5p %c{1}:%L - %m%n"));
         smtpAppender.activateOptions();
         // add email appender
         lg.addAppender(smtpAppender);
    log4j.xml
    <?xml version="1.0" encoding="UTF-8"?><!DOCTYPE log4j:configuration SYSTEM "log4j.dtd" >
    <log4j:configuration>
         <appender name="file"
              class="org.apache.log4j.RollingFileAppender">
              <param name="maxFileSize" value="100KB" />
              <param name="maxBackupIndex" value="5" />
              <param name="File" value="logs/log.txt" />
              <param name="threshold" value="info"/>
              <layout class="org.apache.log4j.PatternLayout">
                   <param name="ConversionPattern"
                        value="%d{ABSOLUTE} %5p %c{1}:%L - %m%n" />
              </layout>
         </appender>
         <appender name="mail" class="org.apache.log4j.net.SMTPAppender">
              <param name="SMTPHost" value="smtp.something.com" />
              <param name="From" value="[email protected]" />
              <param name="To" value="[email protected]" />
              <param name="Subject" value="[LOG] ..." />
              <param name="BufferSize" value="1" />
              <param name="threshold" value="error" />
              <layout class="org.apache.log4j.PatternLayout">
                   <param name="ConversionPattern"
                        value="%d{ABSOLUTE} %5p %c{1}:%L - %m%n" />
              </layout>
         </appender>
         <root>
              <priority value="debug"></priority>
              <appender-ref ref="file" />
              <appender-ref ref="mail"/>
         </root>
    </log4j:configuration>
    log4j.properties
    log4j.rootLogger=warn, file, mail
    log4j.appender.file=org.apache.log4j.RollingFileAppender
    log4j.appender.file.maxFileSize=100KB
    log4j.appender.file.maxBackupIndex=5
    log4j.appender.file.File=D:\log.txt
    log4j.appender.file.threshold=info
    log4j.appender.file.layout=org.apache.log4j.PatternLayout
    log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
    #email appender
    log4j.appender.mail=org.apache.log4j.net.SMTPAppender
    #defines how othen emails are send
    log4j.appender.mail.BufferSize=1
    log4j.appender.mail.SMTPHost="smtp.something.com"
    [email protected]
    [email protected]
    log4j.appender.mail.Subject=Log ...
    log4j.appender.mail.threshold=error
    log4j.appender.mail.layout=org.apache.log4j.PatternLayout
    log4j.appender.mail.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
    Please help me in fixing the problem.....
    Is this code correct to send email...??

    I've not reviewed all of your code/config there, but the error seems to me to indicate a problem parsing your log4j.xml file - have you been able to get a simple configuration working? Can you parse other XML files?
    Good Luck
    Lee

  • Using StringMatchFilter in Log4J XML Config. File?

    I'm trying to use the StringMatchFilter in an appender to determine based on the contents of the message when to send an email, when testing with single words it works great. For example if the message has "Here is a DEBUG" and my "StringToMatch" value is DEBUG then that message is correctly identified. However if I want to match on more specific string like "Here is DEBUG" for my "StringToMatch" value it will match on every message that has the word "Here" in it anywhere. So it would incorrectly match on "Here is a WARN" when the "StringToMatch" value specified is "Here is DEBUG". Below are my two files I'm using to run my test. How should I specify a string with embedded spaces for this to work? I've tried with single quotes inside the double quotes like this: "'Here is DEBUG'" but it still matched on 'Here'.
    My XML Config. file looks like this:
    <?xml version="1.0" encoding="UTF-8" ?>
    <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
    <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
      <appender name="EMAIL"  class="org.apache.log4j.net.SMTPAppender">
              <param name="BufferSize" value="512" />
              <param name="SMTPHost" value="???" />
              <param name="From" value="???" />
              <param name="To" value="???" />
              <param name="Subject" value="Test LogMessage" />
              <layout class="org.apache.log4j.PatternLayout">
                      <param name="ConversionPattern" value="[%d{ISO8601}]%n%n%-5p%n%n%c%n%n%m%n%n" />
              </layout>
              <filter class="org.apache.log4j.varia.StringMatchFilter">
                      <param name="StringToMatch" value="Here is DEBUG" />
                      <param name="AcceptOnMatch" value="true" />
              </filter>
              <filter class="org.apache.log4j.varia.LevelRangeFilter">
                      <param name="LevelMax" value="FATAL"/>
                      <param name="LevelMin" value="DEBUG"/>
              </filter>
      </appender>
      <root>
        <appender-ref ref="EMAIL"/>
      </root>
    </log4j:configuration>and my test java code looks like this:
    import org.apache.log4j.Logger;
    import org.apache.log4j.xml.DOMConfigurator;
    public class Test{
       static Logger logger = Logger.getLogger(Test.class);
       public static void main(String args[]) {
          DOMConfigurator.configure("/home/agsteam/testing/log4j/Test.xml");
          logger.debug("Here is DEBUG");
          logger.info("Here is some INFO blah");
          logger.warn("Here is some WARN");
          logger.error("Here");
          logger.fatal("fatal here");
    }In the above example code every logger message matches, the debug, info, warn, error and fatal all match because of the the 'here' that is found in the message, even though the filter StringToMatch values has "Here is DEBUG".
    Thanks for any help.

    There's an XML parser in the tomcat common diretories. Check out the documentation for XML parser on www.java.sun.com for descriptions.
    Basically there's two levels of XML parsing, the first generates "events" for tags, attributes etc. the second comiples into a tree of Node objects.

  • How i configure the log4j.xml in weblogic server

    hi
    i write a new lg4j.xml and i put this in WEB-INF/classes,i deployed this jar in my remote server,but it not reflected. [i am not specify the server logs, we have some API's which is deployed in server for that API log files is configured using log4j.xml ]
    i saw there is a option in weblogic - setDomain -LOG4J_CONFIG_FILE='here we give the path for log4j.xml'.I think it's only work for local machines not for the remote machines.
    i don't know how to get a log files in weblogic server

    To use Quartz primarily within an application server environment,include the Quartz JAR within the enterprise application (.ear or .war file). However, if you want to make Quartz available to many applications then simply make sure it's on the classpath of your appserver.
    You can also deploy it as a jar file or a library module as required.
    Quartz depends on a number of third-party libraries (in the form of jars) which are included in the distribution .zip file in the 'lib' directory. To use all the features of Quartz, all of these jars must also exist on your classpath.
    -Sandeep

  • How to store user input as an xml Parameter value in log4j.xml?

    I am working on an app that is blend of log4j , EJBs, JMS, weblogic.
    In log4j, I have specified the value of  file appender;
    but now what I  wanna do is: Take path for File (For File Appender) from user and use it as a File path for File Appender in log4j.xml 
    Kindly guide me
    Thank you!

    I think the display of the trace in a standard WDA-component would be the best solution. Maybe Carsten Ziegler can help.
    You can return the trace from the BRFplus-function call and can extract everything using XSLT (CALL TRANSFORMATION command):
    <xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:sap="http://www.sap.com/sapxsl" xmlns:asx="http://www.sap.com/abapxml" version="1.0">
      <xsl:strip-space elements="*"/>
      <xsl:template match="/">
        <asx:abap>
          <asx:values>
            <ROOT>
              <xsl:apply-templates/>
            </ROOT>
          </asx:values>
        </asx:abap>
      </xsl:template>
      <xsl:template match="/FDT/LOG/TEXT">
        <item>
          <xsl:value-of select="string(.)"/>
         </item>
         <xsl:apply-templates/>
      </xsl:template>
      <xsl:template match="/FDT/LOG/CONTEXT_UPDATE">
        <item>
          <xsl:value-of select="concat(string(@DataObjectName), ' is assigned to ' , string(text()))"/>
         </item>
         <xsl:apply-templates/>
      </xsl:template>
      <xsl:template match="text() | @*">
      </xsl:template>
    </xsl:transform>
    You have to adjust the transformation to get the result you need.
    Best Regards,
    Tobias
    P.S.: I'm still thinking about a better solution...

  • Cost involved in changing the code using log4j.properties to log4j.xml

    i have finished my application, and it was done in such a way that logging is done using log4j but it was using log4j.properties file.
    now i need to change it to log4j.xml. i need to do this at the earliest. so i need to know the cost involved in it?. do i need to change a lot on my app to read the log4j.xml?. In my app there is a function named getProperties, which actually reads the log4j.properties file.
    this is the code of that function
    public static Properties getProperties(String filename,String path) throws myException
    //InputStream is = null;
    FileInputStream is=null;
            Properties props = new Properties();       
            //ClassLoader classLoader = ResourceUtil.class.getClassLoader();
            //is = classLoader.getResourceAsStream(filename);
            File catalinaHome = new  File(System.getProperty("catalina.home"));     
            try {       
    is=new
    FileInputStream(catalinaHome.getCanonicalFile()+path + filename);
    } catch (IOException e) {
            if(is == null)
                String message = "Cannot locate property file " + filename + " in the classpath";
                log.error(message);
            throw new myException(message);
            try
                props.load(is);
            catch (IOException e)
                String message = "Error reading property file " + filename;
                log.error(message);
            throw new myException(message, e);
            finally
                try
                    is.close();
                catch(Throwable t)
                    t.printStackTrace();
            if(props.isEmpty())
                String message = "No properties are defined in " + filename;
                log.error(message);
            throw new myException(message);
            return props;       
    }and my initialize function is
    public static void initialize()
    Properties properties=null;
    try {
    String path="/properties/";
    properties=ResourceUtil.getProperties("log4j.properties",path);
    } catch (myException e2) {
    e2.printStackTrace();
    PropertyConfigurator.configure(properties);
    }Message was edited by:
    xema
    Message was edited by:
    xema
    Message was edited by:
    xema

    >
    1. Restructure log4j.properties into log4j.xml.
    thats done
    2. Move log4j.xml into a directory that's in the
    classpath.
    actually i donot understand what does it mean to move in a directory thats in classpath means. i have to use logging in my webapplication running in tomcat. and my log4j.xml has to reside in catalina.home/properties/. My log4j.properties have been residing here and it had worked well woth the previous function. Now what i did is placed the log4j.xml under properties folder. Now tell me what modifications should i make in the above code.
    3. Remove any code that explicitly configures log4j
    (i.e. the initialize() method) because log4j will
    configure itself from any properties file it finds in
    the classpath, automatically, the first time it is
    called.I prefer not remvoing this function as this function is being called in many of my classes... and we don't have time to edit all...
    please help... and excuse me if i asked some blunders.!!!

  • Problem while loading the log4j.xml in to the classpath

    Hi,
    I am working with a web application using tomcat5.0.I am using log4j for logging the information in my application.I am keeping log4j.xml out side of the application(Generally we will keep under WEB-INF/classes ).Now I want to load the log4j.xml from outside location in my ContextListner class.I am using the following code.
    String cmd="java -cp -Dlog4j.configuration=C:/sample/log4j.xml";
                   Runtime runtime = Runtime.getRuntime();
                   Process process = null;
                   process = runtime.exec(cmd);  but I am getting the following errors.
    log4j:WARN File option not set for appender [stdout].
    log4j:WARN Are you using FileAppender instead of ConsoleAppender?
    log4j:WARN No appenders could be found for logger (org.apache.catalina.session.ManagerBase).
    log4j:WARN Please initialize the log4j system properly.
    log4j:ERROR No output stream or file set for the appender named [stdout].
    Feb 26, 2009 7:48:28 PM org.apache.coyote.http11.Http11BaseProtocol startI am not getting where am I doing wrong.
    Any Ideas please?
    Regards
    kondal

    My log4j.xml looks like
    <?xml version="1.0" encoding="UTF-8" ?>
    <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
    <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
         <appender name="file" class="org.apache.log4j.RollingFileAppender">
              <param name="File" value="C:\\niablogs\\niab3.log"/>
            <param name="MaxFileSize" value="1MB"/>
            <param name="append" value="true"/>
            <param name="MaxBackupIndex" value="5"/>
              <layout class="org.apache.log4j.PatternLayout">
                   <param name="ConversionPattern" value="(%-25.25F:%4L) %d{yyyy MM dd HH:mm:ss:SSS} [%-30.30t] %5p - %m %n" />
              </layout>
         </appender>
        <logger name="in.co" additivity="false">
            <level value="all" />
            <appender-ref ref="file" />
        </logger>
    </log4j:configuration>It is working fine if I keep log4j.xml under WEB-INF/classes.If I keep my log4j.xml is outside of the application then it is not working.As per ApacheLog4j Specification we need to set the xml file path to the log4j.configuration system property.Even I tried putting like the following in my Listener class System.setProperty("log4j.configuration", "C:/kondal/log4j.xml");.
    Any Ideas please?
    Thanks
    kondal

  • How to make changes effect in log4j.xml without restarting weblogic server

    Hi ,
    I have successfully configured log4j in my weblogic server 8.1.
    Everytime i made a change in log4j.xml i need to restart the server
    is there any configuration or parameter to set without restarting server??
    Thanks in advance,
    CK

    I don't think you need to restart the server, atleast I never needed to when making changes to jsp pages. You only need to restart when you make changes to java classes. Some might argue jsp is converted to servlet which is a java class.....
    Try refreshing the page when you make any changes. This works for me, if it doesn't work try turning reloadable="true" in your context path in tomcat's server.xml

  • Log4j.properties or log4j.xml Not Reading

    Hello,
    I am trying to use log4j in jsp.
    I have added log4j.properties in /WEB-INF/log4j.properties.
    And in jsp page, I added like
    Logger logger = Logger.getLogger("test1.jsp");When I run jsp page, I get
    log4j:WARN No appenders could be found for logger (test1.jsp).
    log4j:WARN Please initialize the log4j system properly.
    log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.Is this the right place to keep log4j.properties file? Does java classes can read if I put under /WEB-INF folder?
    If I am using log4j.xml where to keep this file?
    Regards
    Edited by: Chackochen on Aug 14, 2010 1:19 AM
    Edited by: Chackochen on Aug 14, 2010 1:20 AM

    Here is what I figured:
    add properties to the workspace/WEIB-INF/directory.xml and then read them from the PAPI code using
         String myProp = DirectoryConfigurationManager.getRuntime("default").getConfigurationProperty("categoryName", "propKey");

  • After Making Changes In Log4j.xml Application Needs Recompilation?

    Hello,
    I am using log4j in my jsp pages and for that I instantiating Logger class like this
    Logger logger = Logger.getLogger("test.jsp");
    {code}
    And I have log4j.xml in the classpath.
    I believe, priority levels can be changed and log level can be changed without re-compiling.
    Change the log4j.xml and re-run jsp pages.
    However I need to re-compile after making changes in log4j.xml file. Without re-compilation changes are not getting reflected.
    Why I need to re-compile application in order to see the changes I have made in log4j.xml?
    Appreciate any help in this regard.
    Regards                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    This is the contents of my log4j.xml, its under WEB-INF/lib
    <?xml version="1.0" encoding="UTF-8" ?>
    <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
    <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
      <!-- A1 is set to be a ConsoleAppender -->
      <appender name="sout" class="org.apache.log4j.ConsoleAppender">
        <!-- A1 uses PatternLayout -->
        <layout class="org.apache.log4j.PatternLayout">
          <param name="ConversionPattern" value="%d [%c] %p - %m%n"/>
        </layout>
      </appender>
      <root>
        <!-- Set root logger level to DEBUG and its only appender to A1 -->
        <priority value="off"/>
        <appender-ref ref="sout"/>
      </root>
    </log4j:configuration>

  • Log4j.xml ----timestamp error-the hour is not correct in the logs. HELP !!!

    I need your help to correct the following issue:
    -timestamp in logs is one hour ahead than the server time.
    I am using jboss-4.0.3SP1 and jdk1.5.0_10
    In order to solve this problem I have tried almost everything that I could find about this on internet:
    1) I have used the tzdupdate()
    tzupdater version 1.3.40-b01
    JRE time zone data version: tzdata2011h
    Embedded time zone data version: tzdata2011h
    2) copied the log4j.properties to WEB-INF/classes
    /opt/jboss-4.0.3SP1/server/mcdp-std/deploy/axis2.war/WEB-INF/classes/log4j.properties
    3) also I've checked to have the same log4j.jar
    The log4j.xml looks like this:
    &lt;?xml version="1.0" encoding="UTF-8"?&gt;
    &lt;!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"&gt;
    &lt;!-- ================================================== --&gt;
    &lt;!-- --&gt;
    &lt;!-- Log4j Configuration --&gt;
    &lt;!-- --&gt;
    &lt;!-- ================================================== --&gt;
    &lt;log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false"&gt;
    &lt;!-- Default server.log file containing the error messages for all clients --&gt;
    &lt;appender name="SERVER_LOG" class="org.jboss.logging.appender.RollingFileAppen der"&gt;
    &lt;errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler "/&gt;
    &lt;!-- Change this value before load test --&gt;
    &lt;param name="Threshold" value="DEBUG"/&gt;
    &lt;param name="File" value="${jboss.server.home.dir}/log/server.log"/&gt;
    &lt;param name="Append" value="true"/&gt;
    &lt;param name="MaxFileSize" value="10MB"/&gt;
    &lt;param name="maxBackupIndex" value="5"/&gt;
    &lt;param name="bufferedIO" value="false"/&gt;
    &lt;layout class="org.apache.log4j.PatternLayout"&gt;
    &lt;param name="ConversionPattern" value="%d{MM/dd HH:mm:ss,SSS} %-5p [%c] %t: %m%n"/&gt;
    &lt;/layout&gt;
    &lt;!-- Exclude partition crap logged in cluster.log --&gt;
    &lt;filter class="org.apache.log4j.varia.StringMatchFilter"&gt;
    &lt;param name="StringToMatch" value="org.jboss.ha"/&gt;
    &lt;param name="AcceptOnMatch" value="false"/&gt;
    &lt;/filter&gt;
    &lt;filter class="org.apache.log4j.varia.StringMatchFilter"&gt;
    &lt;param name="StringToMatch" value="org.jgroups"/&gt;
    &lt;param name="AcceptOnMatch" value="false"/&gt;
    &lt;/filter&gt;
    &lt;/appender&gt;
    &lt;!-- Clustering logging --&gt;
    &lt;appender name="CLUSTER" class="org.jboss.logging.appender.RollingFileAppen der"&gt;
    &lt;errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler "/&gt;
    &lt;!-- Change this value before load test --&gt;
    &lt;param name="Threshold" value="INFO"/&gt;
    &lt;param name="File" value="${jboss.server.home.dir}/log/cluster.log"/&gt;
    &lt;param name="Append" value="true"/&gt;
    &lt;param name="MaxFileSize" value="500KB"/&gt;
    &lt;param name="MaxBackupIndex" value="1"/&gt;
    &lt;layout class="org.apache.log4j.PatternLayout"&gt;
    &lt;param name="ConversionPattern" value="%d{MM/dd HH:mm:ss,SSS} (%t) %-5p [%c] %m%n"/&gt;
    &lt;/layout&gt;
    &lt;/appender&gt;
    and log4.properties is like this:
    # Set root category priority to INFO and its only appender to CONSOLE.
    log4j.rootCategory=INFO, CONSOLE
    #log4j.rootCategory=INFO, CONSOLE, LOGFILE
    # Set the enterprise logger priority to FATAL
    log4j.logger.org.apache.axis2.enterprise=FATAL
    log4j.logger.de.hunsicker.jalopy.io=FATAL
    log4j.logger.httpclient.wire.header=FATAL
    log4j.logger.org.apache.commons.httpclient=FATAL
    # CONSOLE is set to be a ConsoleAppender using a PatternLayout.
    log4j.appender.CONSOLE=org.apache.log4j.ConsoleApp ender
    log4j.appender.CONSOLE.layout=org.apache.log4j.Pat ternLayout
    log4j.appender.CONSOLE.layout.ConversionPattern=%p [%d{ISO8601}] %c{2} %x - %m%n
    # LOGFILE is set to be a File appender using a PatternLayout.
    log4j.appender.LOGFILE=org.apache.log4j.FileAppend er
    log4j.appender.LOGFILE.File=axis2.log
    log4j.appender.LOGFILE.Append=true
    log4j.appender.LOGFILE.layout=org.apache.log4j.Pat ternLayout
    log4j.appender.LOGFILE.layout.ConversionPattern=%p [%d{ISO8601}] %c{2} %x - %m%n

    Did you check http://www.oracle.com/technetwork/java/javase/dst-faq-138158.html in particular 27 about Cached instances of timezone data? I suggest to post this issue in the Application Server forum Oracle Application Server - General

  • Adobe Drive 4 - log4j.xml settings ignored

    I've been looking at Adobe Drive 4, both with our custom connector and the sample connectors, and I can't get any changes to the log4j.xml file to be honored. I can adjust the log level from the "Settings" panel of the Adobe Drive 4 Connect UI, but that has two major limitations: 1) It only goes to the "Info" level (there's no Debug or Trace), and 2) Only the com.adobe.* packages get logged
    I'm editing the log4j.xml file in what I believe is the correct location for AD4 (C:\Program Files\Common Files\Adobe\AD4ServiceManager\configuration). 
    I've added a logger for the sample connectors as described in the SDK documentation:
    <logger name="sample">
          <level value="DEBUG" />
      </logger>
    I've also tried manually setting the Root Logger's Priority:
    <root>
            <priority value="debug"></priority>
            <appender-ref ref="AdobeCSIDefaultAppender"/>
        </root>
    But after doing this launching Drive, then using the FTP sample connector, no log messages for the connector ever get added to the log file.  I know I'm looking at the correct log file because it gets updated with messages from the com.adobe classes. 
    As a test, I also added a call to a com.adobe Logger from within a FTP connector handler class, and it gets added just fine.  For example, from within the sample FTP GetChildrenHadler:
    Logger.getLogger(Path.class).info("TEST MESSAGE");  <---  Appears in Log file
    Logger.getLogger(GetChildrenHandler.class).info("TEST MESSAGE");  <---  Does not appear in Log file
    Is there something else I need to do to get AD4 to use the log4j.xml configuration? 

    Hi Jianfeng, thanks for your response.
    I tried making only the change you suggested, but the result was the same.
    I reverted back to the original log4j.xml (as installed), then replaced the com.adobe logger with the sample logger as you suggested (full file contents below).  After making the change and restarting Adobe Drive, I still get the same behavior as I mentioned in my original post. 
    To recap (all of these test calls were put at the beginning of the FTP connector's GetChildrenHander.execute() method) :
    Using a com.adobe logger, messages show up based on the Log Level setting in the Adobe Drive UI dialog:
    Logger.getLogger(Path.class).debug("TEST MESSAGE")  <-- Never appears in log file
    Logger.getLogger(Path.class).info("TEST MESSAGE")  <-- Appears if Log Level setting is Info
    Logger.getLogger(Path.class).warn("TEST MESSAGE")  <-- Appears if Log Level setting is Info or Warn
    Logger.getLogger(Path.class).error("TEST MESSAGE")  <-- Always appears
    Using a sample package logger, only ERROR and FATAL-level messages show up, regardless of the Log Level setting in the Adobe Drive UI dialog.  I assume this is because the Root logger threshold is fixed at ERROR level.  For example:
    Logger.getLogger(GetChildrenHandler.class).debug("TEST MESSAGE");  <---  Does not appear in Log file
    Logger.getLogger(GetChildrenHandler.class).info("TEST MESSAGE");  <---  Does not appear in Log file
    Logger.getLogger(GetChildrenHandler.class).warn("TEST MESSAGE");  <---  Does not appear in Log file
    Logger.getLogger(GetChildrenHandler.class).error("TEST MESSAGE");  <---  Appears in Log file
    Thanks for your help,
    Brian (aka GoColts)
    Full log4j.xml file contents (after replace com.adobe logger with sample logger):
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd" >
    <log4j:configuration>
        <!-- DO NOT CHANGE THIS APPENDER -->
        <appender name="AdobeCSIDefaultAppender" class="org.apache.log4j.RollingFileAppender">
            <param name="maxFileSize" value="1MB" />
            <param name="maxBackupIndex" value="5" />
            <param name="File" value="${user.dir}/logs/AD4ServiceManager_java.log" />
            <layout class="org.apache.log4j.PatternLayout">
                <param name="ConversionPattern"
                    value="%d{yyyy/MM/dd HH:mm:ss,SSS} [%t] %-5p %c{1} - %m %n" />
            </layout>
        </appender>
        <logger name="sample">
            <level value="debug" />
        </logger>
        <logger name="org.hibernate.cache.ReadWriteCache">
            <level value="error" />
        </logger>
        <!-- AbstractFlushingEventListener will always log StaleObjectStateExceptions, even when handled later on -->
        <logger name="org.hibernate.event.def.AbstractFlushingEventListener">
            <level value="fatal" />
        </logger>
        <root>
            <priority value="error"></priority>
            <appender-ref ref="AdobeCSIDefaultAppender"/>
        </root>
    </log4j:configuration>

  • Importing log4j.xml and viewing the out put .

    hi iam having log4j.xml which i should use to view the output .iam using netbeans IDE .i imported import org.apache.log4j.Logger; then i added log4j.xml in source package .and apache log4j to the libraries .
    *.but how to import this log4j.xml file and view the output?*
    import java.util.logging.Level;
    import org.apache.log4j.Logger;
    static Logger logger = Logger.getLogger( Header.class);the how to use * logger* to view ConsoleAppender and PatternLayout

    Open a text editor. Go to the File menu and select the Open option. Navigate to the directory where the log4j.xml file is located. Select it and it will appear in your text editor, where you will be able to view it.
    That wasn't what you meant, was it? Unfortunately I can't understand what you do mean. You seem to be confusing the act of writing a program which will write output to a file with the act of looking at that file. And you seem to be confusing Java programming operations ("import") with something else that I don't understand.
    Could you rephrase your question and perhaps include something that explains what you want to do? Because you have it backwards. Loggers don't view files, viewing is reading. Loggers write files.

  • Log4j is not identifying ${catalina.home} in log4j.xml

    hi,
    I am trying to print my debug statements in .log file. When i try the full path like
    *<param name="File" value="*c:/Dbg/debug.log*" />* it is succsfully printing the file but if i give like
    it is not printing *"${catalina.home}/Dbg/debug.log"* what is the error.
    ThanQ
    my log4j.xml is as follows:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd" >
    <log4j:configuration>
    <appender name="debugfile"
              class="org.apache.log4j.RollingFileAppender">
              <param name="maxFileSize" value="100KB" />
              <param name="maxBackupIndex" value="5" />
              <param name="File" value="*${catalina.home}/Dbg/debug.log*" />
              <layout class="org.apache.log4j.PatternLayout">
                   <param name="ConversionPattern"
                        value="%d{ABSOLUTE} %5p %c{1}:%L - %m%n" />
              </layout>
              <filter class="org.apache.log4j.varia.LevelRangeFilter">
                   <param name="LevelMin" value="debug" />
                   <param name="LevelMax" value="debug" />
              </filter>
         </appender>
    <root>
              <priority value="debug"></priority>
              <appender-ref ref="debugfile" />
         </root>
    </log4j:configuration>

    No, you didn't replace the system property identifier by the value of the system property. Your XML looks like this:
    <param name="File" value="${catalina.home}/Dbg/debug.log" />(I'm assuming you don't really have those asterisks in there, you were just trying to draw attention to it.) So after replacing the system property, it should look like this:<param name="File" value="D:\MQS\jboss As\Tomcat 5.0/Dbg/debug.log" />Here's another question for you to think about: are system property names case-sensitive or not? catalina.home or CATALINA.HOME?

  • Multiple log4j.xml files for single application.

    Hi All,
    How to use multiple log4j.xml files for single application?
    I do have a pluggable application modules. ie, If I add a jar I will get some functionalities. Like that i do have many jars.
    Log4j.xml also will be present in that jar only. So if I add multiple jar files like this, I will get multiple log4j.xml files. What should I do?

    Each logger can have its own file I think. Check the log4j documentation.

Maybe you are looking for