Log4j on Resin problem

Hi,
I wrote a small web application in Java which implements log4j. I wrote it on my personnal computer which runs Linux. When I try to run it on my website (which is a Windows server), I get some errors.
I sometimes get this one:
500 Servlet Exception java.lang.NoSuchFieldError: level
at org.apache.log4j.spi.RootLogger.setLevel(RootLogger.java:65)
at org.apache.log4j.spi.RootLogger.<init>(RootLogger.java:44)
at org.apache.log4j.LogManager.<clinit>(LogManager.java:78)
at org.apache.log4j.Logger.getLogger(Logger.java:103)
at com.alaxos.blog.database.MySQLBlogConnector.<init>(MySQLBlogConnector.java:43)
at com.alaxos.blog.database.BlogConnectorAdapter.<init>(BlogConnectorAdapter.java:54)
at com.alaxos.blog.tag.SelectBlogDBTagSupport.doStartTag(SelectBlogDBTagSupport.java:52)
at _blog._index__jsp._jspService(/blog/index.jsp:21)
at com.caucho.jsp.JavaPage.service(JavaPage.java:75)
at com.caucho.jsp.Page.subservice(Page.java:485)
at com.caucho.server.http.FilterChainPage.doFilter(FilterChainPage.java:182)
at com.caucho.server.http.Invocation.service(Invocation.java:311)
at com.caucho.server.http.CacheInvocation.service(CacheInvocation.java:135)
at com.caucho.server.http.RunnerRequest.handleRequest(RunnerRequest.java:342)
at com.caucho.server.http.RunnerRequest.handleConnection(RunnerRequest.java:272)
at com.caucho.server.TcpConnection.run(TcpConnection.java:137)
at java.lang.Thread.run(Thread.java:536)and sometimes this one:
java.lang.NoClassDefFoundError
     at org.apache.log4j.Logger.getLogger(Logger.java:103)
     at com.alaxos.blog.database.MySQLBlogConnector.<init>(MySQLBlogConnector.java:43)
     at com.alaxos.blog.database.BlogConnectorAdapter.<init>(BlogConnectorAdapter.java:54)
     at com.alaxos.blog.tag.SelectBlogDBTagSupport.doStartTag(SelectBlogDBTagSupport.java:52)
     at _blog._index__jsp._jspService(/blog/index.jsp:21)
     at com.caucho.jsp.JavaPage.service(JavaPage.java:75)
     at com.caucho.jsp.Page.subservice(Page.java:485)
     at com.caucho.server.http.FilterChainPage.doFilter(FilterChainPage.java:182)
     at com.caucho.server.http.Invocation.service(Invocation.java:311)
     at com.caucho.server.http.CacheInvocation.service(CacheInvocation.java:135)
     at com.caucho.server.http.RunnerRequest.handleRequest(RunnerRequest.java:342)
     at com.caucho.server.http.RunnerRequest.handleConnection(RunnerRequest.java:272)
     at com.caucho.server.TcpConnection.run(TcpConnection.java:137)
     at java.lang.Thread.run(Thread.java:536)In order to debug the java.lang.NoClassDefFoundError, I tried to make my classes recompile by deleting the .class files on my website, after removing the log4j package from my 'lib' directory.
In this case, I get an error saying the package cannot be found. Hence, I suppose the classpath is correct.
The java webserver I use is resin-2.1.2.
Does anyone has a clue about the problem ?
Thanks

I think i get the same problem as u mentioned in this thread.
check the diferent version's log4j.jar file in the classpath or ur web application.u will find the solution of this problem!
good luck!

Similar Messages

  • Log4j and Tomcat-problem

    Hi all,
    First I tried to add some logging to my simple Java code with a xml configuration file and it worked fine.
    Now I am trying to add logging to the whole java application in the same way which runs in tomcat and face with the foll problem.Tomcat is not able to find the configuration file.I tried to place the xml file in all feasible locations in tomcat and also tried to add in classpath but in vain.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`
    Java Code(Which gets called in startup by another code)
    Java Code
    public class PublisherPoll implements Runnable {
    public static Logger logger = Logger.getLoggerPublisherPoll.class);//***********log4j
    public static Logger getLoggerInstance(){   //***********log4j
         return logger;
    static{
    DOMConfigurator.configure("sudarson.xml");//**********its telling it cant find/open this xml file
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Error(during starting tomcat)
    log4j:ERROR Could not open [sudarson.xml].
    java.io.FileNotFoundException: sudarson.xml (The system cannot find the file sp
    cified)
    at java.io.FileInputStream.open(Native Method)
    at java.io.FileInputStream.<init>(FileInputStream.java:106)
    at java.io.FileInputStream.<init>(FileInputStream.java:66)
    at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.jav
    :583)
    at org.apache.log4j.xml.DOMConfigurator.configure(DOMConfigurator.java:
    87)
    at SerenaStartupServlet.init(SerenaStartupServlet.java:44)
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper
    java:1091)
    at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:9
    5)

    DOMConfigurator.configure("sudarson.xml");//**********its telling it cant find/open this xml fileWhat does "sudarson.xml" mean to you? To me, it means a file name relative to the current directory. What do you think the current directory is when you're running this in Tomcat?
    You need to research the APIs more fully, to figure out how to give it a resource name relative to the application's classpath, and put that file in said classpath.
    If I were you, I would try to avoid explicitly calling DOMConfigurator.configure altogether, and just pass the appropriate Log4J system property to the commandline that starts up Tomcat. Let Log4J worry about loading the file, given the property. If I recall correctly, the system property name is "log4j.configuration", which defaults to "log4j.properties" if unspecified. Also, rather than have each application running in Tomcat have their own log4j configuration file name, I'd name them something more universal, like "log4j.xml" - then if you deploy multiple apps in Tomcat, they can all load their own log4j.xml file, as long as (again) you corrected the "log4j.configuration" system property.

  • Struts, log4j, commons-logging problems in 9.0.4 too??

    ok... I have a J2EE project that uses struts, log4j, a couple ejbs. I can successfully deploy and run on JBoss. However, our client insists that we use the 10g App Server, so I tried to deploy on 10g v10.1.2 (after making the appropriate changes to the deployment descriptors); the ear file deployed without problems, but when using the application, I encountered the following error when the app got to part of my code that tries to create a log file using the commons-logging framework:
    java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
    I see from these forums that there is a known problem regarding commons-logging and log4j with v10.1.2 (Help: 10g, struts, commons-logging and log4j doesn't work in 10g!? 9i fine! )..... so, I installed v9.0.4 of the 10g AppServer, deployed and ...... drum roll please.... I get the same error.
    The commons-logging.jar file IS in the [application dir]/WEB-INF/lib directory so the app should be finding the org.apache.commons.logging.LogFactory class file. And - struts is working based on page navigation prior to hitting the error (which I've heard indicates that the commons-logging.jar library is being invoked at some point).
    So... am I missing something? or does v9.0.4 also have the bug (related to classloaders)???
    sure hope someone can help....
    Scott

    I don't know why it's not working either, unless it's related to that classloader issue.... I have the following files in my WEB-INF/lib directory:
    commons-beanutils.jar
    commons-collections.jar
    commons-digester.jar
    commons-logging.jar
    commons-validator.jar
    jakarta-oro.jar
    log4j-1.2.9.jar
    struts.jar
    ScottsTester-ejb.jar (my ejb classes)
    ScottsTester-web.jar (my struts-related classes)
    I'm running into problems when the app tries to create an instance of my ejb (which has as a member variable an org.apache.commons.logging.Log object which is created by the org.apache.commons.logging.LogFactory object - the Oracle App Server is telling me it can't find the LogFactory class despite the fact that the commoons-logging.jar file is in the WEB-INF/lib directory.... and, as other postings have noted, this appears to be a problem with the classloaders. Unfortunately, the workaround suggesting by Qiang causes problems with my ejbs - when I try to get a home object, I encounter a ClassCastException somewhere in the PortableRemoteObject.narrow(o, DbConnectionHome.class); call..... maybe Oracle should stick to databases.....

  • Log4j properties configuration problem

    Hi all,
    I have problem to configure properties , below is sample configuration i used :
    log4j.rootCategory=,R1,R2
    #configuration for trace
    log4j.appender.R1.Threshold=DEBUG
    log4j.appender.R1=org.apache.log4j.FileAppender
    log4j.appender.R1.File=trace.out
    log4j.appender.R1.layout=org.apache.log4j.PatternLayout
    log4j.appender.R1.layout.ConversionPattern=%p %d{dd MMM yyyy HH:mm:ss} %m
    log4j.appender.R1=org.apache.log4j.RollingFileAppender
    #configuration for error
    log4j.appender.R2.Threshold=ERROR
    log4j.appender.R2=org.apache.log4j.FileAppender
    log4j.appender.R2.File=error.out
    log4j.appender.R2.layout=org.apache.log4j.PatternLayout
    log4j.appender.R2.layout.ConversionPattern=%p %d{dd MMM yyyy HH:mm:ss} %m
    log4j.appender.R2=org.apache.log4j.RollingFileAppender
    How to disable error log in trace.out file , i want to error log only in error.out file, but acctualy error log still appears in trace.out.
    thanks all

    avoid setting Threshold. instead use a specific logger in your class for errors:
    public final static Logger sysErrLog = Logger.getLogger("SystemError");
    and configure this logger in the log4j.properties:
    log4j.logger.SystemError=ERROR, SystemErrorLogFile
    log4j.additivity.SystemError=false
    log4j.appender.SystemErrorLogFile=org.apache.log4j.RollingFileAppender
    log4j.appender.SystemErrorLogFile.File=${LogDir}/systemerror.log
    log4j.appender.SystemErrorLogFile.append=true
    log4j.appender.SystemErrorLogFile.layout=org.apache.log4j.PatternLayout
    log4j.appender.SystemErrorLogFile.layout.ConversionPattern=%d{ISO8601} %c{2} - %m%n
    log4j.appender.SystemErrorLogFile.MaxFileSize=1000KB
    log4j.appender.SystemErrorLogFile.MaxBackupIndex=3

  • Weblogic 6.1 and Resin Problems

    I am having trouble with Weblogic 6.1 and Resin. I have a simple .jsp
              page that calls an entity bean I have created and deployed with
              Weblogic.
              The key aspects of the JSP are as follows:
                        Context jndiContext = new InitialContext();
                        Object ref = ic.lookup("java:comp/env/CustomerHomeRemote");
                        CustomerHomeRemote home = (CustomerHomeRemote)
                             PortableRemoteObject.narrow(ref,CustomerHomeRemote.class);
                        Integer pk = new Integer(1002);
                        CustomerRemote customer = home.findByPrimaryKey(pk);
                        out.print(customer.getFirstname() +"<br>");
                        out.print(customer.getLastname() +"<br>");
              My resin.conf is the same as the default with the following added:
              <classpath id='c:\Smartix-Apps\lib\smartixejb.jar' />
              <classpath id='c:\Smartix-Apps\classes' />
              <classpath id='c:\temp\caucho' />
              <classpath id='c:\Smartix-Apps\lib\resin.jar' />
              <classpath id='C:\Programs\bea\wlserver6.1\lib\weblogic.jar' />
              <jndi-link>
              <jndi-name>java:comp/env/CustomerHomeRemote</jndi-name>
              <jndi-factory>weblogic.jndi.WLInitialContextFactory</jndi-factory>
              <init-param java.naming.provider.url="t3://localhost:7001"/>
              <jndi-lookup>CustomerHomeRemote</jndi-lookup>
              </jndi-link>
              smartixejb.jar contains the CustomerEJB and \classes has all the class
              files.
              The error I am getting is:
              500 Servlet Exception
              java.lang.ClassCastException:
              com.caucho.server.http.ApplicationAdapter
                   at com.caucho.jsp.PageManager.<init>(PageManager.java:83)
                   at com.caucho.jsp.JspManager.<init>(JspManager.java:75)
                   at com.caucho.jsp.JspServlet.init(JspServlet.java:74)
                   at com.caucho.server.http.Application.createServlet(Application.java:2755)
                   at com.caucho.server.http.Application.loadServlet(Application.java:2711)
                   at com.caucho.server.http.Application.getFilterChainServlet(Application.java:2478)
                   at com.caucho.server.http.Application.buildFilterChain(Application.java:2445)
                   at com.caucho.server.http.Invocation.service(Invocation.java:276)
                   at com.caucho.server.http.CacheInvocation.service(CacheInvocation.java:129)
                   at com.caucho.server.http.RunnerRequest.handleRequest(RunnerRequest.java:338)
                   at com.caucho.server.http.RunnerRequest.handleConnection(RunnerRequest.java:270)
                   at com.caucho.server.TcpConnection.run(TcpConnection.java:140)
                   at java.lang.Thread.run(Thread.java:484)
              Can anyone help me???
              Thanks in advance!
              

    Remove <classpath id='c:\Smartix-Apps\lib\resin.jar' /> from
              your resin.conf.
              Matt Koidin <[email protected]> wrote:
              > I am having trouble with Weblogic 6.1 and Resin. I have a simple .jsp
              > page that calls an entity bean I have created and deployed with
              > Weblogic.
              > The key aspects of the JSP are as follows:
              >           Context jndiContext = new InitialContext();
              >           Object ref = ic.lookup("java:comp/env/CustomerHomeRemote");
              >           CustomerHomeRemote home = (CustomerHomeRemote)
              >                PortableRemoteObject.narrow(ref,CustomerHomeRemote.class);
              >           Integer pk = new Integer(1002);
              >           CustomerRemote customer = home.findByPrimaryKey(pk);
              >           out.print(customer.getFirstname() +"<br>");
              >           out.print(customer.getLastname() +"<br>");
              > My resin.conf is the same as the default with the following added:
              > <classpath id='c:\Smartix-Apps\lib\smartixejb.jar' />
              > <classpath id='c:\Smartix-Apps\classes' />
              > <classpath id='c:\temp\caucho' />
              > <classpath id='c:\Smartix-Apps\lib\resin.jar' />
              > <classpath id='C:\Programs\bea\wlserver6.1\lib\weblogic.jar' />
              >
              > <jndi-link>
              > <jndi-name>java:comp/env/CustomerHomeRemote</jndi-name>
              > <jndi-factory>weblogic.jndi.WLInitialContextFactory</jndi-factory>
              > <init-param java.naming.provider.url="t3://localhost:7001"/>
              > <jndi-lookup>CustomerHomeRemote</jndi-lookup>
              > </jndi-link>
              > smartixejb.jar contains the CustomerEJB and \classes has all the class
              > files.
              > The error I am getting is:
              > 500 Servlet Exception
              > java.lang.ClassCastException:
              > com.caucho.server.http.ApplicationAdapter
              >      at com.caucho.jsp.PageManager.<init>(PageManager.java:83)
              >      at com.caucho.jsp.JspManager.<init>(JspManager.java:75)
              >      at com.caucho.jsp.JspServlet.init(JspServlet.java:74)
              >      at com.caucho.server.http.Application.createServlet(Application.java:2755)
              >      at com.caucho.server.http.Application.loadServlet(Application.java:2711)
              >      at com.caucho.server.http.Application.getFilterChainServlet(Application.java:2478)
              >      at com.caucho.server.http.Application.buildFilterChain(Application.java:2445)
              >      at com.caucho.server.http.Invocation.service(Invocation.java:276)
              >      at com.caucho.server.http.CacheInvocation.service(CacheInvocation.java:129)
              >      at com.caucho.server.http.RunnerRequest.handleRequest(RunnerRequest.java:338)
              >      at com.caucho.server.http.RunnerRequest.handleConnection(RunnerRequest.java:270)
              >      at com.caucho.server.TcpConnection.run(TcpConnection.java:140)
              >      at java.lang.Thread.run(Thread.java:484)
              > Can anyone help me???
              > Thanks in advance!
              Dimitri
              

  • MDB Container Managed Transaction and Log4J

    Hi,
    I'm programming and MDB that reads and updates a database then sends out an HTTP Post and logs using log4j. I've read that when an MDB is configured as CMT or container managed transaction and the OnMessage method executes without errors, the transaction is implicitly commited. You can rollback the transaction by explicitly calling setRollbackOnly() or when a RuntimeException has been thrown. My worry is that after I have sent out an HTTP POST (a transaction has been completed) I would have to log a transaction completion using log4j. My problems is if log4j throws a RuntimeException thereby rolling back my transaction which shouldn't be the case. What I have done is to catch all Exceptions (and swallow them) whenever I log using log4j after I have sent out an HTTP POST succesfully (since my transaction should be complete by then). Is this a correct workaround?
    Thanks :)

    Your approach is correct. If you think, Log4J might throw errors, swallow the exceptions and try not to roll back.

  • Log4j classes not found in custom RoleMapper (sometimes)

    WLS8.1 sp2, using wlserver ant task to start the server. Not sure if this is
    the best group, but...
    I have a custom RolerMapper provider that I can successfully add to a
    running server through the admin console, but when I try to start the server
    via ant (essentially a coldstart with a saved config.xml file,
    boot.properties and ldift files), the server throws a NoClassDefFoundError:
    [wlserver] <Mar 19, 2004 2:57:08 PM EST> <Info> <Security> <BEA-090075>
    <The RoleMapper provider has had its LDIF information loaded from:
    C:\bea\user_projects\domains\combinenet\.\DefaultRoleMapperInit.ldift>
    [wlserver]
    [wlserver] The WebLogic Server did not start up properly.
    [wlserver] java.lang.NoClassDefFoundError: org/apache/log4j/Logger
    [wlserver] at com.combinenet.util.Logger.<init>(Logger.java:113)
    [wlserver] at com.combinenet.util.Logger.getLogger(Logger.java:125)
    [wlserver] at com.combinenet.util.Logger.getLogger(Logger.java:136)
    [wlserver] at
    com.combinenet.security.CNRoleMapperProvider.<clinit>(CNRoleMapperProvider.j
    ava:65)
    I tried adding "Class-Path: log4j.jar" to the manifest of the provider jar
    file, and I even stuffed the log4j.jar in there too, but neither worked.
    log4j.jar is in the server's common/lib directory, and other parts of our
    app use log4j without a problem.
    I worked around this by unjarring log4j.jar and updating my provider jar
    with all of the classes, but obviously isn't a solution.
    Any idea why log4j.jar isn't being loaded by the server's bootstrap
    classloader at startup (from common/lib)?
    How can I add log4j.jar to the classpath in the wlserver task? (it doesn't
    support the classpath attribute).
    I've had more problems getting log4j to work properly with WLS...
    Thanks for any help,
    Miles

    I ran in the same problem... I tried to autogenerate the Manifest file from the
    weblogicMbeanMaker with no success. So instead of hacking the Manifest file (I
    could not do it from ANT)., I conceded the game to weblogic and put the log4j.jar
    in the Classpath in startWebLogic.cmd/startWebLogic.sh.
    It worked.
    How do you change the manifest? After generating the .jar or did u find a work
    around for the webLogicMbeanMaker class?
    "Miles Krivoshia" <mkrivoshia{{remove}}@combinenet.{{rem}}com> wrote:
    FYI, if anyone is interested, putting the log4j.jar in the mbeantypes
    directory and using the Class-Path: log4j.jar entry in the provider's
    manifest file got around this problem. It seems that jars in the system
    classpath is not available to security provider jars for some reason.
    I
    don't recall seeing that documented anywhere.
    "Miles Krivoshia" <mkrivoshia{{remove}}@combinenet.{{rem}}com> wrote
    in
    message news:[email protected]...
    Thanks for the reply. I have tried placing the jar in the system classpath
    (that's how our ejbs access log4j, just fine), but that didn't workeither.
    Seems to be something special about provider jars. I'll follow up onthe
    mgmt newsgroup.
    -Miles
    "Craig" <[email protected]> wrote in message
    news:[email protected]...
    I believe you will need to place the jar in the system classpath.
    You
    can
    ask about
    provider jars and using the class path from the manifest file in
    the
    weblogic.developer.interest.management
    newsgroup.
    "Miles Krivoshia" <mkrivoshia{{remove}}@combinenet.{{rem}}com> wrote:
    WLS8.1 sp2, using wlserver ant task to start the server. Not sure
    if
    this is
    the best group, but...
    I have a custom RolerMapper provider that I can successfully addto a
    running server through the admin console, but when I try to startthe
    server
    via ant (essentially a coldstart with a saved config.xml file,
    boot.properties and ldift files), the server throws aNoClassDefFoundError:
    [wlserver] <Mar 19, 2004 2:57:08 PM EST> <Info> <Security>
    <BEA-090075>
    <The RoleMapper provider has had its LDIF information loaded from:
    C:\bea\user_projects\domains\combinenet\.\DefaultRoleMapperInit.ldift>
    [wlserver]***************************************************************************
    [wlserver] The WebLogic Server did not start up properly.
    [wlserver] java.lang.NoClassDefFoundError: org/apache/log4j/Logger
    [wlserver] at com.combinenet.util.Logger.<init>(Logger.java:113)
    [wlserver] at
    com.combinenet.util.Logger.getLogger(Logger.java:125)
    [wlserver] atcom.combinenet.util.Logger.getLogger(Logger.java:136)
    [wlserver] atcom.combinenet.security.CNRoleMapperProvider.<clinit>(CNRoleMapperProvider.
    j
    ava:65)
    I tried adding "Class-Path: log4j.jar" to the manifest of the provider
    jar
    file, and I even stuffed the log4j.jar in there too, but neither
    worked.
    log4j.jar is in the server's common/lib directory, and other partsof
    our
    app use log4j without a problem.
    I worked around this by unjarring log4j.jar and updating my provider
    jar
    with all of the classes, but obviously isn't a solution.
    Any idea why log4j.jar isn't being loaded by the server's bootstrap
    classloader at startup (from common/lib)?
    How can I add log4j.jar to the classpath in the wlserver task? (itdoesn't
    support the classpath attribute).
    I've had more problems getting log4j to work properly with WLS...
    Thanks for any help,
    Miles

  • How to create different log files for different users in log4j

    I want to create different logs for different users, using different appenders for each user so that logs are created in his file only.
    Confusion:How to direct them to different files in my logger class

    Hi Avi,
    First of all I have given a first reading to log4j and I think there will some more easy way of logging debugging messages than log4j (If you could provide me a detailed explanation of a servlet,jsp,java bean that uses log4j and how to use log4j then it will be very helpful for me). The other easy ways (if I am not using log4j) to my problem i.e creating different log files for each of web applications deployed in oc4j are
    I have created multiple instances of OC4J that are configured to run on different ports and so on each instance I have deployed a single web application . And I started the 2 oc4j instances by transferring thier error/log messages to a file. And the other way is ..
    I have download from jakarta site a package called servhelper . This servhelper is a thread that is started in a startup servlet and stopped in the destroy method of that startup servlet. So this thread will automatically capture all the system.out.println's and will print those to a file. I believe that this thread program is synchronized. So in this method I need not run multiple instances of OC4J instead each deployed web application on single instance of oc4j uses the same thread program (ofcourse a copy of thread program is put in each of the deployed web applications directories) to log messages on to different log files.
    Can you comment on my above 2 approached to logging debugging messages and a compartive explanation to LOG4J and how to use LOG4J using a simple servlet, simple jsp is appreciated ...
    Thanks and Regards,
    Ravi.

  • Log4j and jsf

    I added log4j in my application. It is working and I can see my log.debug statements in the console. The problem is that I can see more than I want. My application uses jsf and Tomcat and I see many jsf debugs and I do not know what to change in my log4j.properties so as not to view them. My log4j.properties is the following:
    log4j.rootLogger=debugLog, stdout
    # CONSOLE appender
    log4j.appender.stdout=org.apache.log4j.ConsoleAppender
    log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
    log4j.appender.stdout.layout.ConversionPattern=%d{HH:mm:ss} %-5p %m%n
    log4j.appender.debugLog=org.apache.log4j.DailyRollingFileAppender
    log4j.appender.debugLog.Threshold=debug
    log4j.appender.debugLog.layout=org.apache.log4j.PatternLayout
    log4j.category.com.corejsf = debugLog
    I tried to add something like the following
    log4j.category.com.sun.faces = WARN
    log4j.additivity.com.sun.faces=falsebut nothing changed.Any suggestions??

    This is a log4j properties file problem. I'm not used to using the .properties file notation. I'm used to the XML notation for log4j.
    Here's how I'd do it in XML:
    <?xml version="1.0" encoding="UTF-8" ?>
    <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
    <log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/'>
            <!--
                    Set up the appender
            -->
            <appender name="Appender" class="org.apache.log4j.ConsoleAppender">
                    <param name="Append" value="true"/>
                    <layout class="org.apache.log4j.PatternLayout">
                            <param name="ConversionPattern" value="%d{HH:mm:ss} %-5p %m%n"/>
                    </layout>
            </appender>
            <logger name="my.java.package" additivity="false">
                    <level value="debug" />
                    <appender-ref ref="Appender" />
            </logger>
            <logger name="another.package.for.debug.level" additivity="false">
                    <level value="debug" />
                    <appender-ref ref="Appender" />
            </logger>
            <!--
                    Omitting the JSF package altogether should remove the undesired
                    DEBUG messages from it. However, if not, uncomment the following
                    lines.
            -->
            <!-- <logger name="javax.faces" additivity="false">
                    <level value="INFO" />
                    <appender-ref ref="Appender" />
            </logger> -->
            <root>
               <priority value ="debug" />
               <appender-ref ref="Appender" />
            </root>
    </log4j:configuration>This example will print to console only. If you want to print to a file instead, use the following lines (replaces the appender tags from the above example).
            <appender name="Appender" class="org.apache.log4j.DailyRollingFileAppender">
                    <param name="File" value="filePath/FileName.log"/>
                    <param name="DatePattern" value="'.'yyy-MM-dd"/>
                    <param name="Append" value="true"/>
                    <layout class="org.apache.log4j.PatternLayout">
                            <param name="ConversionPattern" value="%d{HH:mm:ss} %-5p %m%n"/>
                    </layout>
            </appender>I don't know how you'd get both the console and the file appender working at the same time.
    If you want further advice, or If you want advice on the .properties method of doing things, I suggest finding a log4j forum. The people there will undoubtedly have more experience and knowledge than us JSF nerds. =)
    I assure you though, JSF is compatible with log4j. The log4j properties file just needs to be set up properly (more challenging than it should be, if you ask me).
    CowKing

  • Log4j SMTPAppender Experience

    Hey everyone... couldn't find a better place to post this, so here it goes.
    Has anyone used the SMTPAppender for log4j? The reason I ask this question is because I have a very high availability production server which is using this appender. It points to a remote SMTP server... this SMTP server was taken offline temporarily this AM. At that point the log4j appender wasn't able to communicate with it.
    I am not totally sure how or why this problem occured, but it appears that log4j completely destroyed the TCP/IP stack on my server. Existing connections to the server started getting dropped, RDP response time got very slow, and eventually my server couldn't communicate with the mySQL server anymore. At first it appeared a switch went down... but we went to the failover hardware and it didn't stop the problem. I was getting a ton of "java.io.IOException: An established connection was aborted by the software in your host machine" on connections which have absolutely nothing to do with log4j.
    After about 2 hours of downtime, I disabled the SMTPAppender in log4j and all problems went away... This wasn't a hardware issue, we went to 2 different failover servers (same experience). The ony thing it could have been was the fact that the log4j SMTPAppender couldn't send emails...
    Anyone?

    I am using the log4j SMTPAppender for several production systems. I usually only get a few messages each day, probably similar to the number you expect. However I haven't yet had the situation where the SMTP server goes down.
    Wait a minute -- I did have almost that situation! The network people upgraded our server by putting a new version of McAfee antivirus onto it, and they left the checkbox "Don't let this machine be used for bulk e-mails" checked, which meant it wasn't allowed to connect to port 25 on other systems. And all that happened was that log4j output a message to the System.err log saying there was some kind of error. I didn't even notice for several days that there was a problem.
    Maybe the difference was that in my case log4j didn't already have a connection to the server when the server "went down", but maybe in your case it did have a connection. But I wouldn't expect the appender to hold on to the session, I would only expect it to get a session when it needed to send a message. Could be wrong though, the source code is available to look at.

  • J2EE and log4j

    I am probably asking to do the impossible ! But I will try anyway !
    We are trying to implement a logging system (with log4j) for an application that executes tasks. The specification is to generate a seperate log file for each task that is executed. We have managed to implement this utilizing the MDC schema of log4j.
    The problem is that the application is comprised of many applications (EAR's) and log4j is only capturing the information logged from the EAR that initialized the log. Is there anyway for log4j to 'track' the transaction through all the EJB's (in different applications) and log the information to the same appender ?
    I know that JMS will resolve this problem but unfortuneatly at this moment we cannot use JMS at this time.
    Thanks in advance for any comments or sugestions !

    >
    Now the next problem is how to create the same logs
    across VM's , ie one EJB calling another remotely and
    the log for the transaction continues in the same
    file.Two different processes? That isn't a good idea. There is no way to synchronize access so it will end overwriting entries.
    You can use a third process which does the actual logging. The other two processes use the appropriate appender to send it to the remote logger.

  • How to create different log files for each of web applications deployed in OC4J

    Hi All,
    I am using OC4J(from Oracle) v1.0.2.2 and Windows2000. Now I want to know
    1. how to create different log files for each of my deployed web applications ?
    2. what are the advantages in running multiple instances of oc4j and in what case we should run
    multiple instances of OC4J ?
    3. how to run OC4J as Windows2000 Service rather than Windows2000 Application ?
    Thanks and Regards,
    Kumar.

    Hi Avi,
    First of all I have given a first reading to log4j and I think there will some more easy way of logging debugging messages than log4j (If you could provide me a detailed explanation of a servlet,jsp,java bean that uses log4j and how to use log4j then it will be very helpful for me). The other easy ways (if I am not using log4j) to my problem i.e creating different log files for each of web applications deployed in oc4j are
    I have created multiple instances of OC4J that are configured to run on different ports and so on each instance I have deployed a single web application . And I started the 2 oc4j instances by transferring thier error/log messages to a file. And the other way is ..
    I have download from jakarta site a package called servhelper . This servhelper is a thread that is started in a startup servlet and stopped in the destroy method of that startup servlet. So this thread will automatically capture all the system.out.println's and will print those to a file. I believe that this thread program is synchronized. So in this method I need not run multiple instances of OC4J instead each deployed web application on single instance of oc4j uses the same thread program (ofcourse a copy of thread program is put in each of the deployed web applications directories) to log messages on to different log files.
    Can you comment on my above 2 approached to logging debugging messages and a compartive explanation to LOG4J and how to use LOG4J using a simple servlet, simple jsp is appreciated ...
    Thanks and Regards,
    Ravi.

  • Logging through sockets

    Hi
    I'm trying to send logging information through sockets using log4j.
    My configuration file is :
    log4j.rootLogger=Debug, Socket
    log4j.appender.Socket=org.apache.log4j.net.SocketAppender
    log4j.appender.Socket.Port=12345
    log4j.appender.Socket.RemoteHost=localhost
    log4j.appender.Socket.LocationInfo=true
    the server only reads the input string that the logger sends.
    I'm getting this exception on the client side:
    log4j:WARN Detected problem with connection: java.net.SocketException: Software caused connection abort: socket write error
    and this message on the server:
    Server started...
    Client accepted
    ������������org.apache.log4j.spi.LoggingEven�������������

    Ryan,
    I think if I could log to something common like Microsoft Access it would be a help to me in managing database backups and other things, as Citadel is somewhat unique in its format and methods using the Measurement and Automation Explorer. Maybe I could retrieve data from a 3rd party database back into Citadel if Citadel DB becomes corrupted or lost.
    I don't use ODBC logging now, so please excuse me if I come across as lacking in understanding your request. Could the hypertrend or other objects be programmed to log and/or retrieve data to and/or from the 3rd party ODBC database as well?
    Terry Parks, Engineering Analyst
    Terrebonne Parish Consolidated Government (T.P.C.G.)
    Public Works - Pollution Control

  • The SQL query is not executing

    Hi
    I have the following situation: In a project we designed our reports calling a stored procedure the exits in a MS SQL Server 200 database. The Stored Procedures works fine and when they are used in the report everything works perfectly.
    The reports are being made with CR DEsigner 11, when the designer ends them, ha pass them to me and we put them in our java web application. I open them and even preview them since the Crystal Reprots Perspective of Eclipse and I can see the data, so everything to this point is OK.
    The problem comes when I change of connection, I'm trying to connect every report to the same host and database, and when the reprot is displayed in the browser there is no data. I profile the SQL commands that are executed when the report is requested and I found that the reprot is not executing the stored procedure.
    I guess because i'm connectring the report to the same database and host that was used when the report is created and i'm also passing exactly the same parameters of the stored procedure, then report thinks that it doesn't have executing again becuase it will be the same information.
    SO, i wonder if there is a way to request to the report to execute the sql query every time i have to display it.
    thanks for any help.

    What happens when you try to view the report using a simple viewer.jsp?without changing the connection?
    2009-05-25 14:06:09,250 ERROR com.businessobjects.reports.sdk.JRCCommunicationAdapter -  detected an exception: Error de conexión: [SQLServer 2000 Driver for JDBC]Error establishing socket.
    But the database server is ok, so i think the rpt needs more information to be connect to the database.
    Also what happens if you dont use the data bean and give everything there only?
    The same, the rpt is not executing the stored procedure.
    Did anything change on the RDBMS side? Additional packages, changes to the schema, ownership, etc?
    No, the server is ok and the database is ok.
    If you configure Log4J logging to DEBUG, you should see the database invokes from the Crystal Java engine, specifically the queries sent and the number of rowsets returned. Do you notice any errors?
    I have a problem here with log4j. In my project i'm using spring and with the help of spring i configure log4j, basically with spring is easier to configure log4j.
    I'm telling you this because i have log4j working but when my application reaches the code to change the connection to the rerport, log4j dies and stop sending any message to the stdout or to a log file. I haven't since this behavior in any other app o library. So i want to guess i have something wrong with my log4j or maybe with log4j+spring.
    So, i remove all the code of spring referring to log4j, but the problem with log4j wasn't solved.
    What i will try now is to remove spring from the project.
    This is my log4j.properties:
    log4j.rootLogger=DEBUG, stdout
    log4j.appender.stdout=org.apache.log4j.ConsoleAppender
    log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
    log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - %m%n

  • Logging Best Practices in J2EE

    Hi,
    I've been struggling with Apache Commons Logging and Log4J Class Loading problems between module deployments in the Sun App Server. I've also had the same problems with other App servers.
    What is the best practice for Logging in J2EE.
    i.e. I think i may be java.util.logging. But what is the best practise for providing different logging config (i.e. Levels for classes and output) for each deployed module. and how would you structure that in the EAR.
    Thanks in advance.
    Graham

    I find using the java.util.logging works fine. For configuration of the log levels I use a LifeCycle module that sets up all my levels and handlers. That way I can set up the server.policy to allow only the LifeCycle module jar to configure logging (with a codebase grant), but no other normal modules can.
    The LifeCycle module gets its properties as event data with the INIT event and configures the logging on the STARTUP event.
    Hope this helps.

Maybe you are looking for