Doubt using log4j

Hi there,
I'm using jboss3.2.5 to access my java applications.
I would like to make a different log directory to each application. Is this possible using log4j ? (i've never tried it)
If so, how do i set the log4j properties for each application to use ?
Thanks,

Have you tried setting the file parameter to point to a different location?
  <appender name="myAppender" class="org.apache.log4j.DailyRollingFileAppender">
    <param name="DatePattern"    value="yyyy-MM-dd"/>
    <param name="File"           value="./logs/myLogName.log" />
    <param name="Append"         value="false" />
    <layout class="org.apache.log4j.PatternLayout">
      <param name="ConversionPattern" value="%-5p : %d{yyyy/MM/dd : HH:mm:ss} : %l : %x : %m%n"/>
    </layout>
  </appender>

Similar Messages

  • Doubt abt Log4j

    hi to all.
    i have doubt in Log4j. to create log i have done code as follows..
    static Category cat = Category.getInstance(LogTest.class.getName());
    PropertyConfigurator.configure("../webapps/CSPPS/WEB-INF/classes/CustomLog.properties");
    cat.info("Address");
    (1) When i compied my LogTest class compile successfully and run too. but when the compile time the msg comes like
    Note: Some input files use or override a deprecated API.
    Note: Recompile with -deprecation for details.
    (2)if i give without full path like above error has come.. hw would i avoid it..
    (3)i have to write log file depends upon the day.. ex..if i run march 3 005 then the file name comes like MyLog.2005-03-03 and create another date like MyLog.2005-03-04.... how to do this..
    give ur valueable suggestion..
    thx n adv..with regards
    DJ

    i have doubt in Log4j. Me too!

  • Need Some Help in Using Log4j for logging

    Hi
    I am using Log4j for logging in my application . i have problem some areas .
    I want to rotate my file on basis of Time. means if my log file name format is HH:MM then after every minute new log file should be created , i am using Size based rotation its working fine.
    Plz Tell me which propety i used to set my logfile name like DATeFormat
    i tried with this Property but failed
    log4j.appender.R.File=%d{HH:MM}
    Simlarly i dont want to bound BackupSize
    log4j.appender.R.MaxBackupIndex=1000
    i want that suppose after 2 Mb automatically start new file and there is no upper bound on that
    how can i do that or from where i can see all properties of Log4j Thanks

    Thanks
    But in this case i cannot do Size based rotation
    These properties not belong to DialyRolling.. class
    log4j.appender.R.MaxFileSize=1KB
    log4j.appender.R.MaxBackupIndex=1000
    what i want is if file size grow with in one minute i create new file using RollingFileApender and if size doesnt grow in one minute and minute cross then next minute file should be created , how can i acheive both of these

  • 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.!!!

  • How to create the log file in remote system using log4j.

    Hi,
    How to create the log file in remote system using log4j. please give me a sample code or related links.The below example i used for create the log file in remote system but it return the below exception.Is there any authandication parameter for accessing the remote path? Please help.
    public class Logging
    Logger log=null;
    FileAppender fileapp=null;
    public Logging(String classname)
    try
    log = Logger.getLogger(classname);
    String path=" [\\192.168.0.14\\c$\\LOG\\d9\\May_08_2008_log.txt|file://\\192.168.0.14\\c$\\LOG\\d9\\May_08_2008_log.txt]";
    fileapp = new FileAppender(new PatternLayout("%r [%t] %-5p %c %x - %m%n"),path, true);
    log.addAppender(fileapp);
    log.info("Logger initilized");
    }catch(Exception ex)
    ex.printStackTrace();
    java.io.FileNotFoundException: \\192.168.0.14\c$\LOG\d9\May_08_2008_log.txt (The network path was not found)
    at java.io.FileOutputStream.openAppend(Native Method)
    at java.io.FileOutputStream.<init>(Unknown Source)
    at java.io.FileOutputStream.<init>(Unknown Source)
    at org.apache.log4j.FileAppender.setFile(FileAppender.java:290)
    at org.apache.log4j.FileAppender.<init>(FileAppender.java:109)
    at annwyn.logger.BioCapLogger.<init>(Logging.java:23)
    at sun.applet.AppletPanel.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
    Please help.
    Thanks in advance.
    Saravanan.K

    Sorry path is missing for the above request.
    path="\\192.168.0.14\c$\LOG\d9\May_08_2008_log.txt ";
    please help.
    Saravanan.K

  • Problem in using log4j..i'm getting warning!!!

    i have been using log4j without any porblems. i have placed the log4j.properties file under classes folder under WEB-INF and it worked.
    but now i'm asked to place it under a folder named properties under CatalinaHome. And i came to know tht there is no problem in doing so and i just changed the path in my code.
    but now i'm getting the following warnings.. but logging is also going well..
    what could be the reson for this warning.
    log4j:WARN No appenders could be found for logger (com.servlet.Search
    Profile).
    log4j:WARN Please initialize the log4j system properly.

    Hi
    Have not come across a situation to limit the number of records in APD while processing, we have several DTP's extracting quite high volume of data and processing it further. (Including Cumulative & Non-cumulative key figures)
    However please be informed that the processing will fail if the query execution runs out of memory due to high volume of data.
    Based on the above screen shot it seems to be a warning message but will process the data.
    Regards
    Ashish 

  • Error in Logging using log4j When deployed in weblogic server

    I have deployed an SOAP based web service application as an war file and used log4j propertiers to do application logging .When i tested the application through a JAVA client the log4j log file has all the application log information but when i deployed it in the weblogic server 10.3.3 and tested it through SOAP UI it gives me just "Run time error exception" in the log4j log file(which is returned in the SOAP response) as against the application logs which i need. I have also added <wls:package-name>org.apache.log4j.*</wls:package-name> in the weblogic.xml and also changwed the logging to the log4j logging in the server ( which was perviously JDK logging) .But still it is not returning the complete application error stack trace in the log4j log file(and also in the weblogic command console) I need to get the application error stack trace in the log4j log file ( and also in the console) so it would be easy to debug the code.
    Please help me out in doing the same.
    thanks in advance

    Noman,
    have you checked that the folder D:\OracleJeveloper\Middleware\jdk160_14_R27.6.5-32 contains the jre?
    Timo

  • Using log4j in User definied Extension Function java class

    Hi
    I am having a java class where I defined all the user defined XSL Functions.
    I used System.out.println for printing.
    But I want to use log4j. But when I use this to debug. It is not recognising only.
    Could you please tell me why this is not working in this class?
    Regards,
    Praveena

    Hi Anuj,
    I can see the below error in the default log file:
    09/08/11 16:25:21 log4j:ERROR A "org.apache.log4j.RollingFileAppender" object is not assignable to a "org.apache.log4j.Appender" variable.
    09/08/11 16:25:21 log4j:ERROR The class "org.apache.log4j.Appender" was loaded by
    09/08/11 16:25:21 log4j:ERROR [global.libraries:1.0] whereas object of type
    09/08/11 16:25:21 log4j:ERROR "org.apache.log4j.RollingFileAppender" was loaded by [oracle.bpel.common:10.1.3].
    09/08/11 16:25:21 log4j:ERROR Could not instantiate appender named "LOGFILE".
    09/08/11 16:25:21 log4j:WARN No appenders could be found for logger (oracle.sample.XSLFunction).
    09/08/11 16:25:21 log4j:WARN Please initialize the log4j system properly.
    log4j.properties file:
    # Set root category priority to INFO and its only appender to CONSOLE.
    log4j.rootCategory=INFO, LOGFILE
    # LOGFILE is set to be a File appender using a PatternLayout.
    log4j.appender.LOGFILE=org.apache.log4j.RollingFileAppender
    log4j.appender.LOGFILE.File= C:/product/10.1.3.1/OracleAS_1/opmn/logs/XSLUtilExten.log
    log4j.appender.LOGFILE.Append=true
    log4j.appender.LOGFILE.Threshold=INFO,DEBUG
    log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout
    log4j.appender.LOGFILE.layout.ConversionPattern=<%d>[%t] %p %C: %m%n
    log4j.appender.LOGFILE.MaxFileSize=40MB
    log4j.appender.LOGFILE.MaxBackupIndex=10
    Could you please tell me what is the problem?
    Edited by: Jakarta on Aug 11, 2009 4:16 AM

  • Using Log4J in a Portal Application

    I am using Log4J in my portal app, but no log messages are getting printed. Here
    is what I am doing -
    In a Pageflow I have the following code
    public static final String CLASS_ID = MyPageFlow.class.getName() + " - ";
    private static Logger logger = Logger.getLogger(MyPageFlow.class.getName());
    In the begin method I have -
    logger.debug(CLASS_ID+"In Begin Action");
    Then in my startWebLogic.cmd I have
    set LOG4J=-Dlog4j.config=myconfig\log4j.properties
    And I add this to the start line
    Here is my log4j.properties file
    log4j.rootLogger=debug, stdout, R
    log4j.appender.stdout=org.apache.log4j.ConsoleAppender
    log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
    # Pattern to output the caller's file name and line number.
    log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n
    log4j.appender.R=org.apache.log4j.RollingFileAppender
    log4j.appender.R.File=logs/myspt.log
    log4j.appender.R.MaxFileSize=1000KB
    log4j.appender.R.MaxBackupIndex=100
    log4j.appender.R.layout=org.apache.log4j.PatternLayout
    log4j.appender.R.layout.ConversionPattern=%p %t %c - %m%n
    What could be wrong?
    Thanks in advance.
    Mark

    After read some more forums i notice that i can´t place the dll's on java project, so i placed them on system32.
    Now i don't have any error of Native Library already loaded in another classloader, but i continue with the error UnsatisfiedLinkError: jni_init on line "if ((javacurl_handle = jni_init()) == 0)"
    Does anyone can help me?
    Thanks,
    Luis Cruz

  • Can I use log4j with a java stored procedure

    I have code that resides on the middle tier and on the database. Our company is using log4j for debugging purposes. In order to get my code to work on the database, I have had to remove all the log4j stuff. Has anyone tried to get code that has log4j messages to run on the database? I am not concerned with actual debugging, I just don't want to have to strip this code out if I can avoid it.

    Hi Laura,
    As far as I know, you have two choices:
    1. Load the log4j classes into the database (using the "loadjava" tool).
    2. Enable remote invocation of log4j classes via RMI (or similar).
    Hope this helps.
    Good Luck,
    Avi.

  • Logging using Log4J

    Hi,
    I want to use Log4J to write to the sap log using a Log4J appender. I followed the tutorial from https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/36085e78-0801-0010-678d-8b4e89ddff3c
    but i doesnt work for me. When i check the ear which is deployed to the server, i cant find my log4j.properties file anywhere...i guess that is the problem. I put it in the src folder...i thought it was the correct place, but it doesnt show up in the ear...can anyone help me out?
    Much thanks,
    Hugo Hendriks

    Please don't crosspost. It cuts down on the effectiveness of responses, leads to people wasting their time answering what others have already answered, makes for difficult discussion, and is generally just annoying and bad form.

  • How to use log4j in struts project

    Hi, all
    I want to use log4j and pooling in my running project based on struts-tomcat.
    Can any one tell me all the process in details step by step,to apply in my project
    i m wait for any rply

    Another day, another jargon-dump

  • How to create outside Logging file in osb 11g using log4j.jar?

    Hi all,
    Currently, i am using osb 11g to develop a system. In the system we need to create a log file using log4j.jar library. This sub-program is working in the osb 10g base but fail to work in the osb 11g base. Can anyone give me some advice about this matter? Have anyone created one like this in 11g? Is it successful?

    Sorry path is missing for the above request.
    path="\\192.168.0.14\c$\LOG\d9\May_08_2008_log.txt ";
    please help.
    Saravanan.K

  • Using log4j with portal server

    Hi,
    I am trying to use log4j with Portal server 6.1 using log taglibs from jakarta.
    Here is what i've done:
    1. copy taglibs-log.jar in /etc/opt/SUNWps/desktop/classes
    2. copy taglibs-log.tld in /etc/opt/SUNWps/desktop/default/tld
    3. put log statements in JSPs
    for example:
    <log:debug>This is body content.</log:debug>
    <log:debug message="This is attribute content." />
    4. /etc/opt/SUNWps/desktop/classes/log4j.properties contains
    =========================================
    # Sample properties to initialise log4j
    log4j.rootCategory=debug, stdout, R
    #log4j.rootCategory=debug, stdout
    log4j.appender.stdout=org.apache.log4j.ConsoleAppender
    log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
    # Pattern to output the caller's file name and line number.
    log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n
    log4j.appender.R=org.apache.log4j.RollingFileAppender
    log4j.appender.R.File=logtags.log
    log4j.appender.R.MaxFileSize=100KB
    # Keep one backup file
    log4j.appender.R.MaxBackupIndex=2
    log4j.appender.R.layout=org.apache.log4j.PatternLayout
    log4j.appender.R.layout.ConversionPattern=%p %t %c - %m%n
    ===============================================
    However no log file is created on my system. I am very new to this and would appreciate if anyone could tell me what more needs to be done to get log records in a file.
    Thanks for all your help.
    Kind regards,
    Apoorv

    Hi,
    I am trying to use log4j with Portal server 6.1 using
    log taglibs from jakarta.
    Here is what i've done:
    1. copy taglibs-log.jar in
    /etc/opt/SUNWps/desktop/classes
    2. copy taglibs-log.tld in
    /etc/opt/SUNWps/desktop/default/tld
    3. put log statements in JSPs
    for example:
    <log:debug>This is body content.</log:debug>
    <log:debug message="This is attribute content." />
    4. /etc/opt/SUNWps/desktop/classes/log4j.properties
    contains
    =========================================
    # Sample properties to initialise log4j
    log4j.rootCategory=debug, stdout, R
    #log4j.rootCategory=debug, stdout
    log4j.appender.stdout=org.apache.log4j.ConsoleAppender
    log4j.appender.stdout.layout=org.apache.log4j.PatternL
    ayout
    # Pattern to output the caller's file name and line
    number.
    log4j.appender.stdout.layout.ConversionPattern=%5p
    [%t] (%F:%L) - %m%n
    log4j.appender.R=org.apache.log4j.RollingFileAppender
    log4j.appender.R.File=logtags.log
    log4j.appender.R.MaxFileSize=100KB
    # Keep one backup file
    log4j.appender.R.MaxBackupIndex=2
    log4j.appender.R.layout=org.apache.log4j.PatternLayout
    log4j.appender.R.layout.ConversionPattern=%p %t %c -
    %m%n
    ===============================================
    However no log file is created on my system. I am
    very new to this and would appreciate if anyone could
    tell me what more needs to be done to get log records
    in a file.
    Thanks for all your help.
    Kind regards,
    Apoorv

  • Problen when using log4j.jar in my web service application

    Hi, i have a little problem. I have to migrate an existing java application to web services, and this application uses log4j.jar. So i put that jar file in the lib dir in WEB-INF. However, when i try to deploy the application, i get an error saying
    org.apache.commons.LoggingException: No suitable Log constructor [LJava.lang.Class;c492c8 for org.apache.commons.logging.impl.Log4JLogger
    And of course if i remove that jar from the lib dir, the app deploys ok, but it crashes because it can't find the class Logger (located in that jar)
    Any ideas how to solve this?????
    Thank you                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    When is the log4j constructor invoked ?....you said you moved the java application to webservice....in the java application they might have initialized the log4j with the log4j properties file some where when they start the application..
    Have a start up servlet which initializes the lof4j.

Maybe you are looking for

  • Loading Tracks with the Same Name

    Hi all, brand new iPod owner here! I have some bootleg concerts that I want to load up. I've done two shows successfully, one from a CDR and one direct from my PC's hard drive. All the tracks for these two shows have different names. Now..... what if

  • To copy data from Sales order to subsequent purchase order

    Hi all, My requirement is to copy Ship-to party address and Incoterms from sales order to subsequent Purchase order. I am using exit EXIT_SAPFV45E_001 for this. My doubt is - in which tables, Ship-to party address and Incoterms for a purchase order a

  • General administrator question

    I never understood why there will sometimes be a "grayed out" item in a folder that cannot be seen/chosen in the Discoverer report. (Example: Accounts Payable/Bank Accounts (from apfg_bank_accounts). Item Bank Branch ID) Right now I really would like

  • User not available means schema not existed in the Database?

    Hi Team, I am trying to add primary to existing table. Requester mentioned schrma_name and table_name. I used below query......to find schema existed or not. select USERNAME,ACCOUNT_STATUS from dba_users where username='ABCD_USA_NUM'; no rows selecte

  • MIDI Keyboard Not Working With Logic Pro X

    I have a MIDI keyboard that I've had for a while. I've upgraded to Logic Pro X, but the keyboard isn't working. I can't hear sound when I play it, nor when I record and try to play it back to myself. What's more frustrating is that I used this keyboa