Discussions

General J2EE: JBoss and log4j logging

  1. JBoss and log4j logging (15 messages)

    We have this specific problem related to JBoss-4.0.1 and log4j (which comes inbuilt in JBoss).
    I dont want JBoss's inbuilt log4j to do logging for me.
    I want to make my own log4j.properties file and JBoss on the fly should lift the properties file and log accordingly to files and console for me.
    I tried disabling JBoss's log4j logging. But am unable to do it.

    If I try to run a stand-alone java program (without JBoss Server) with a log4j properties file, it works fine and logs accordingly as given in my properties file.
    But, if I try to run my application (on JBoss), it is not taking my properties file, but it is taking JBoss's log4j.xml and logs accordingly.
    I tried to customize the log4j.xml, even that dint work for me. Then, it logs lots and lots of stuff to the log file, which I give in the xml file.

    I tried deleting all the log4j.xml files, wherever I found in the %JBOSS_HOME% folder and try to keep a log4j.properties file. But even then, JBoss is logging in the server.log file, without even recognising my properties file. Even though, there is no xml file, JBoss logs as if it is lifting all the properties from the xml.

    Please give me a solution to my problem.

    TIA,

    Regards,
    Prashanth Babu.

    Threaded Messages (15)

  2. well[ Go to top ]

    why r u trying to disable jboss's logging ?-

    jboss's logging are very flexible , im running few applications on jboss each one has its own log file - some use the syslog appender some use the file appender
    you can customize it to whatever you like ...
  3. jBoss log4j[ Go to top ]

    you running application in same JVM with jBoss so you'll have to share log4j with it. simplest way - add your loggers/appenders to jBoss
    bit more tricky – load your configuration in addition to jBoss programmatically from application
  4. Set your log4j.properties like this

    log4j.category.com.yourpath.yourclass=, EventLogger
    log4j.appender.EventLogger=org.apache.log4j.RollingFileAppender
    log4j.appender.EventLogger.layout=org.apache.log4j.PatternLayout
    log4j.appender.EventLogger.layout.ConversionPattern=%d{dd/MM/yyyy HH:mm:ss} -%m%n
    log4j.appender.EventLogger.MaxFileSize=100KB
    log4j.appender.EventLogger.MaxBackupIndex=1
    log4j.appender.EventLogger.File=D:\\logs
    your_app.log
    log4j.appender.EventLogger.Append=true

    Jboss continue logging in his folder, and you can put your log in another file
  5. JBoss and log4j logging[ Go to top ]

    I am also having the same problem. I created separate log file for my application using log4j but instead of creating in the path i specified, its getting clubbed with Jboss log file & is getting displayed in Jboss' server.log than creating a separate log file. Wanted a quick response.
  6. If you any of you had any success. Please let me know
  7. I can send the solution, I use, to you, if you are still searching a solution.

    Bye
    Dursun
  8. If you any of you had any success. Please let me know

    My solution is:

    Firstly, you edit the file log4j.xml under the directory conf depending on, which server you use.
    Let's assume, we are using the default. Then we should edit ${jboss.home.dir}\server\default\conf\log4j.xml
    Now we can define an appender for our application in such a way

    <appender name="APPLICATIONNAME_FILE" class="org.apache.log4j.FileAppender">
    <param name="File" value="${jboss.server.home.dir}/log/testlog.log" />
    <param name="Append" value="true" />

    <layout class="org.apache.log4j.PatternLayout">
    <param name="ConversionPattern" value="%d{dd MMM yyy HH:mm:ss}, %-6p %C:%M:%L %m %n" />
    </layout>
    </appender>

    After defined the appender, we can now define our category(Logger)in such a way

    <category name="at.infrasoft.kirkgoeze">
    <priority value="INFO" />
    <appender-ref ref="APPLICATIONNAME_FILE" />
    </category>

    After all this, now you should restart(or start) JBOSS Application Server.
    And finally, you can use it in your EJB-application or Web-application.

    ...
    Logger logger =Logger.getLogger("at.infrasoft.kirkgoeze");
    logger.warn("TEST warn");
    logger.info("TEST info");
    logger.debug("TEST debug");
    ...

    Bye
  9. JBoss and log4j logging[ Go to top ]

    This is very helpful - thanks.
    Note on this - although jboss wiki says to do so, don't add to root logger if you don't want all messages.
    If you any of you had any success. Please let me know
    My solution is:Firstly, you edit the file log4j.xml under the directory conf depending on, which server you use.Let's assume, we are using the default. Then we should edit ${jboss.home.dir}serverdefaultconflog4j.xmlNow we can define an appender for our application in such a way<appender name="APPLICATIONNAME_FILE" class="org.apache.log4j.FileAppender"> <param name="File" value="${jboss.server.home.dir}/log/testlog.log" /> <param name="Append" value="true" /> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" value="%d{dd MMM yyy HH:mm:ss}, %-6p %C:%M:%L %m %n" /> </layout> </appender>After defined the appender, we can now define our category(Logger)in such a way <category name="at.infrasoft.kirkgoeze"> <priority value="INFO" /> <appender-ref ref="APPLICATIONNAME_FILE" /> </category>After all this, now you should restart(or start) JBOSS Application Server.And finally, you can use it in your EJB-application or Web-application....Logger logger =Logger.getLogger("at.infrasoft.kirkgoeze");logger.warn("TEST warn");logger.info("TEST info");logger.debug("TEST debug");...Bye
  10. jboss AS & log4j issue[ Go to top ]

    Hi All,
    Iam trying to use log4j in myapp.war to write to my own application log.
    when I put lo4j.jar in my application, Iam getting classloader exceptions in jboss console
    when I take that out, complete logging ( jboss & myapp) are going into my own log file

    when I commeneted all lines in mylog4j.properties & dont keep log4j jar in myapp, logging is going to server.log

    I have my log4j.properties fiel in myapp\web-inf. I have tried with wiki logging help ny reanming log4j.xml & changing jboss-service.xml, but dint work

    seems to be jboss as is not maintaining multiple log environments

    I dont want to make much changes outside.

    tried out to use a specific classloader in app.war
    jboss-web.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <jboss-web>
    <class-loading java2ClassLoadingCompliance="false">
       <loader-repository>
          myapp:loader=myapp.war
          <loader-repository-config>java2ParentDelegation=false</loader-repository-config>
       </loader-repository>
     </class-loading>
    </jboss-web>


    Please help me out
  11. JBoss and custom log4j logging[ Go to top ]

    We have a situation where we have our own custom logging package (extended from Apache's log4j classes). So if we modify JBoss' log4j.xml, our classes cannot be found. Any suggestions? Thanks
  12. I played with log4j upto a great extent. My required output was supposed to be my own logging mechanism in which i should be able to create userlog.log name kind of different file and logs sholud generate in specific format(name#action#parameter) so that i can read the data easily. I am able to do in some jboss locations as i am testing in many servers before deploying. By modifying in log4j.xml based on appenders(File/Console).But in my local system i am unabe to test it as here file appender is not working.I get a blanck log file but things get logged in server.log here i can't get selective data in selective format. I don't know, i am missing any configuration or jboss server is having any problem or log4j.jar is having prob. For this i repalced many log4j.jar one by one and even set the classpath accordingly.But no benefit. Can anyone guide me what can be the cause of this. Vijendra
  13. If you want your application specific logging configuration independent of JBoss configuration then you should seriously consider rolling out log4j RepositorySelector which provides a clean solution to this problem. Read this excellent article about RepositorySelector here: http://www.qos.ch/logging/sc.jsp Having read that you will see that you need to write a simple custom RepositorySelector that will configure log4j LogManager. You could either do this as part of some init servlet or an JMX mbean or something appropriate. This is a cleaner way and will allow you to have multiple configuration coexist cleanly. JBoss seem to be aware of this and has decided to integrate a RepositorySelector integrated in JBoss 5. You can more details here: http://jira.jboss.com/jira/browse/JBAS-1313?page=history Hope this helps. -Sath
  14. Problem in configuring log4j in Jboss Hi All, I am trying to set up a logger for my web application. I have Jboss 4.0.4 installed on my machine. I am using 'default' configuration of the JBoss server. I have added the follwoing code in my log4j.xml placed at /server/default/conf folder. Code: After doing this, i restarted the Jboss server and deployed my application on Jboss. When i run my application, the log file gets created but no messages are written to it. However all those messages appear in the 'server.log' frile of the Jboss. Can someone tell that what could be th
  15. Your java package structure (for the logged classes) begins with the package 'ppaslogs', as in ppaslogs.foo.bar, ppaslogs.bar.foo etc? Unless that is true, you will not have anything logged, I believe.
  16. Re: JBoss and log4j logging[ Go to top ]

    I Had the same issue, and i've finally found out that i had both log4j.jar and commons-logging.jar in my war file. those jars are already included in JBoss libraries. after solving this duplicity (i just removed those jars from my war) i had everything working ok.