Log4j.properties location

Hello,
I want my web application uses a log4j.properties file located in a directory outside Tomcat, in /var/app/conf/.
I'm using the PropertyConfigurator to configure log4j. If I put log4j.properties in the WEB-INF/classes directory all works fine, but if I put it in the "external" directory works but I get these warnings:
log4j:WARN No appenders could be found for logger (org.apache.catalina.startup.TldConfig).
log4j:WARN No appenders could be found for logger (org.apache.commons.digester.Digester.sax).
How could I avoid these warnings?
Thanks!

I am putting log4j.properties file in same folder
where the java class file is, it's working fine. If
i'm puting it in some different folder (folder is on
class path) it's giving the proper output as log file
but throwing exception at console as:I don't think it's the location of the java class, but rather
where you are when you run the program. I'm running
junit tests from within eclipse, and need to put the file
one directory above my "com" directory. From the
command line, the properties file just needs to be in
the current directory. Perhaps using a fully qualified
path name will solve your problem; no matter where
you run the program, the file will be found. This
assumes you have access to a fully qualified location
(probably bad). Best to determine from where the
program will be run, and place the file in a relative
directory off of that (perhaps at deploy time).
Cheers,
Brian

Similar Messages

  • Log4j.properties location for ant and kodo tools

    Greetings all
    Is it possible to configure the kodo ant tasks,
    such as jdoc (kodo.ant.JDOEnhancerTask) to use
    a log4j.properties file that is not in the
    classpath?
    We generally have our log4j.properties
    file in a separate location away from the classpath
    and for standard junit and java ant targets we can
    set it's location via a jvmarg...
    Version: 3.0.0
    Thanks
    droo.

    Ok thanks for the help.
    Perhaps I could suggest for a future version that the
    Kodo Ant Tasks include the ability to specify a "jvmarg"
    like you can for java and junit targets now, for example:
    <taskdef
    name="jdoc"
    classname="kodo.ant.JDOEnhancerTask"
    classpathref="compile.path" />
    <jdoc>
    <fileset refid="all.jdo.files" />
    <classpath refid="other.path" />
    <config propertiesFile="${kodo.properties}"/>
    <jvmarg value="-Dlog4j.properties=file:///my/log4j/config" /
    >
    <jvmarg value="-Djava.compiler=NONE" />
    <jvmarg value="-Dfred=mary" />
    </jdoc>
    But if not then it's ok too :) Thanks again.
    droo.
    Droo-
    I'm not aware of an ant task to set system properties. You could
    specify it on the command line. E.g.,:
    ant -Dlog4j.configuration=/my/log4j/config mytarget
    You could also install beanshell and use the beanshell target to set
    it. E.g.:
    <target name="setlog4jproperty">
    <script language="beanshell"><![CDATA[
                   System.setProperty ("log4j.configuration", "/my/log4j/config");
    ]]> ]]></script>
    </target>
    See the ant documentation for more on the required dependencies for
    beanshell.
    In article <[email protected]>, droo wrote:
    Yes of course, but the real question is...
    How do I specify a system property for a
    kodo ant task?
    Sorry if this question is too stupid!
    Here is what I have...
    <taskdef
    name="jdoc"
    classname="kodo.ant.JDOEnhancerTask"
    classpathref="compile-path" />
    <jdoc>
    <fileset refid="all-jdo-files" />
    <classpath refid="post-compile-path" />
    <config propertiesFile="${nf.kodo.properties}"/>
    </jdoc>
    In <[email protected]> Marc Prud'hommeaux wrote:
    Droo-
    I think you can specify the "log4j.configuration" system property.
    Take a look at:
    http://jakarta.apache.org/log4j/docs/manual.html
    In article <[email protected]>, droo wrote:
    Greetings all
    Is it possible to configure the kodo ant tasks,
    such as jdoc (kodo.ant.JDOEnhancerTask) to use
    a log4j.properties file that is not in the
    classpath?
    We generally have our log4j.properties
    file in a separate location away from the classpath
    and for standard junit and java ant targets we can
    set it's location via a jvmarg...
    Version: 3.0.0
    Thanks
    droo.

  • WS32 - proper location for log4j.properties?

    Greetings,
    I am running WS3.2 and I have a log4j.properties file located in /resources/* within the IDE.
    As long as I manually copy the file into the "java/classes" directory the file is picked up at runtime.
    Ideally, Workshop should be automagically grabbing the properties file and placing it on the classpath when I "run" the application.
    Is there a workaround for this (besides the manual copy)?
    Is this a defect or am I doing something quite stupid?
    much thks!

    Ok - I've figured this one out.
    The Log4j.properties file needs to reside at:
    web/WEB-INF/src/java.
    Workshop 3.2 DOES copy the file over to the classes director but since I had it in a subfolder called "resources" it wasn't being picked up.

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

  • Changing Log4j properties for the log file

    Hi All
    I want to set up some log4j properties(format ..etc) for the log file located at
    <OracleAS_HOME>\opmn\logs\default_group~home~default_group~1.log
    But i am unable to find the xml file where I can tune the properties. Any pointer will be of great help!!
    Thanks

    Hi
    opmn.xml has entry for opmn\logs\opmn.log only.... can't find the entry for the log file i need
    Thanks

  • Access log4j.properties outside source folder

    Hi,
    I have developed a standalone java application, for logging the application i have created a log4j.properties in the source folder.
    it is woring fine and the logs are created as specified in the properties file.
    Issue:
    i have created a jar which contains the complete source code and log4j.properties file.
    if i try to create a jar without log4j.properties since the properties file will change by customer frequantly, i need to keep the log4j.properties outside the source folder.
    but my jar is unable to access the log4j.properties when i try to run the appplication.
    Question:
    how do we access the log4j.properties from outside source folder?
    thanks,
    J R

    gimbal2 wrote:
    T.PD wrote:
    In addition what gimbal2 sad: Do you create a MANIFEST.MF file in your jar?
    If so you should add (or extend) the ClassPath entry to include the current directory ( *.* ) so you can have the log4j.properties file in the folder where you call your jar from:[...]This is very dangerous. It makes the path not relative to where the jar is, but to where you invoke the java command.The OP's request is to have the (log4j) properties file outside of the jar maybe for easier editing.
    Adding any known folder in the file system to the class path is the only way I know to achieve this (Do you know better?). Folliwing this you could try to guess paths to add hoping that they will exist on all Systems you will use and place the properties file(s) there. On the other hane the current working dir the java command is invoked in is perdictable. Usually it's the directory the jar itself is located...
    I agree that this solution can be dangerous and opens the possibility to access classes located in a valid package structure below current working dir . But if you add the ' *.* ' as the last entry in your classpath at least the classes from all your other jars are accessed first...
    bye
    TPD

  • Log4j.properties - ClassNotFoundException

    I'm using log4j and Weblogic 6.0. I initialize log4j using a startup servlet that loads the log4j.properties file located in WEB-INF\classes. Log4j gets initialized fine, except that I always get
    a ClassNotFound exception because weblogic
    tries to load log4j.properties as a class each time it initializes a webapp. How do I
    remedy this? Thanks.

    Please post start-up servlet code.
    Karen Yang wrote:
    I'm using log4j and Weblogic 6.0. I initialize log4j using a startup servlet that loads the log4j.properties file located in WEB-INF\classes. Log4j gets initialized fine, except that I always get
    a ClassNotFound exception because weblogic
    tries to load log4j.properties as a class each time it initializes a webapp. How do I
    remedy this? Thanks.

  • Security hotfix APSB11-04 - CF8 and log4j.properties

    Hi,
    I have been reviewing the Tech Notes for the security hotfix at http://kb2.adobe.com/cps/890/cpsid_89094.html which for CF 8.01 talks about backing up and replacing the   log4j.properties file. I can't locate this on any of our CF 8.01 servers, so wondering if this is a mistake in the tech note and should have only applied to CF 9. Can I skip the step all together or do I still need to copy the file from the downloaded hotfix to the suggested location?
    Thanks
    Meint

    Hi Meint,
    My CF8.0.1 does not have log4j.properties file either tho CF9.0.1 has.
    HTH, Carl.

  • File not found error with log4j.properties

    Hi,
    I'm writing a web service on weblogic 8.1 with weblogic workshop.I have to use log4j-1.2.7 supplied by client with my application.I cannot write ant script manually.Also I cannot change server start script or cannot put any command line argument when the server starts.
    Now I require this logger in my EJB.I have kept log4j.properties in the same path where my EJB's are.But the final ear produced does not contain this log4j.properties and subsequently I get the error "log4j:ERROR Could not read configuration file [log4j.properties]."
    Please help me to resolve this problem so that log4j.properties goes with the final .ear file and the ejb code finds the logger.
    thanks,
    pratim

    Hello,
    I am having a similar problem. Did you find a solution?
    Thank you,
    Melissa
    "arunak" <[email protected]> wrote:
    >
    Hi Pratim,
    I am also facing the same problem. can u please let me know whenever
    u get the
    solution for this.
    Regards,
    Arunak
    Pratim <[email protected]> wrote:
    Hi,
    I'm writing a web service on weblogic 8.1 with weblogic workshop.Ihave
    to use log4j-1.2.7 supplied by client with my application.I cannot write
    ant script manually.Also I cannot change server start script or cannot
    put any command line argument when the server starts.
    Now I require this logger in my EJB.I have kept log4j.properties inthe
    same path where my EJB's are.But the final ear produced does not contain
    this log4j.properties and subsequently I get the error "log4j:ERROR
    Could not read configuration file [log4j.properties]."
    Please help me to resolve this problem so that log4j.properties goes
    with the final .ear file and the ejb code finds the logger.
    thanks,
    pratim

  • Configuring directory path for fileappender in log4j.properties

    I want to write log data to a file where the directory path of the file should be picked from a unix environmental variable. How can you configure this in log4j.properties?
    log4j.rootLogger=INFO, A
    # A is set to be a FileAppender.
    log4j.appender.A=org.apache.log4j.FileAppender
    # A uses PatternLayout.
    log4j.appender.A.File=$UNIX_ENV_VARIABLE/A.log <= This is what I want. The dir path should be picked from some env path
    log4j.appender.A.layout=org.apache.log4j.PatternLayout
    log4j.appender.A.layout.ConversionPattern=%d{HH:mm:ss,SSS} [%t] %-5p %c %x - %m%n
    Or if this should be done in code, then please guide me on that.
    Thanks in advance

    Hi,
    i am facing one problem,
    where today's log and yesterday log has log statements for today with same date.. but different data. any one pls help.
    this is the properties i configured
    # Logger for A messages
    log4j.logger.A=debug, A_R1
    log4j.appender.A_R1=org.apache.log4j.DailyRollingFileAppender
    log4j.appender.A_R1.File=/var/opt/wmeaidata/app_data/log4j/logs/eai_a.log
    log4j.appender.A_R1.MaxFileSize = 5MB
    log4j.appender.A_R1.MaxBackupIndex = 3
    log4j.appender.A_R1.layout=org.apache.log4j.PatternLayout
    log4j.appender.A_R1.layout.ConversionPattern=%d{MMM dd, yyyy hh:mm:ss a}|%c-%X{host}|%m%n
    Thanks
    venkat

  • A question about log4j.properties

    Normally I put the log4j.properties inside my web-application such as under WEB-INF. So it will be packaged into the WAR.
    But now I want to take it outside of the WAR and put it under a dir and furthermore I change its name to "myLog4j.log4j.properties". This has two advantages:
    1.
    One can change the contents without opent the WAR.
    2.
    Under this dir the other projects can put their xxx.log4j.properties so they can be managed easily.
    But I don't know where should I put this file and how to configure the server sothat the server can find this file and my program can write all the log infos into the log-file defined in the "myLog4j.log4j.properties".
    Can someone help?
    Regards

    Actually file log4j.properties should be in the classpath, that classloader could see it. Add the path to file into CLASSPATH.
    Thanks

  • 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");

  • Problem with log4j.properties and level DEBUG

    Hi,
    I need some log4j help.
    I create 2 different appenders in the log4j.properties file
    and it works.
    This is my complete log4j.properties:
    log4j.logger.log1=DEBUG, log1
    log4j.logger.log2=DEBUG, log2
    log4j.appender.log1=org.apache.log4j.DailyRollingFileAppender
    log4j.appender.log1.File=${StandardLogPath}
    log4j.appender.log1.DatePattern='.'yyyy-MM-dd
    log4j.appender.log1.Append=true
    #log4j.appender.log1.Threshold=DEBUG
    log4j.appender.log1.layout=org.apache.log4j.PatternLayout
    log4j.appender.log1.layout.ConversionPattern=%d{dd MMM yyyy HH:mm:ss} [%-5p] %-25c{1} %m%n
    log4j.appender.log2=org.apache.log4j.DailyRollingFileAppender
    log4j.appender.log2.File=${StandardLogQueryPath}
    log4j.appender.log2.DatePattern='.'yyyy-MM-dd
    log4j.appender.log2.Append=true
    log4j.appender.log2.layout=org.apache.log4j.PatternLayout
    log4j.appender.log2.layout.ConversionPattern=%d{dd MMM yyyy HH:mm:ss} [%-5p] %-25c{1} %m%nAnd here's my logging code:
    import org.apache.log4j.Logger;
    Logger log = Logger.getLogger("log1");
    Logger logQuery = Logger.getLogger("log2");
    log.debug("loggerDebug");
    logQuery.debug("loggerDebug");
    log.info("loggerInfo");
    logQuery.info("loggerInfo");The problem is that "loggerDebug" is not written to all appenders (only "loggerInfo").
    In fact if I print:
    System.out.println( log.getEffectiveLevel().toString() );result that the level is INFO and I known that if level is INFO then DEBUG is disable.
    But why the level is INFO????
    Someone can suggest me a solution?
    Thank you very much

    You're so over-sensitive you: when an OP doesn't respond anymore
    to your last reply it implies that you've solved the problem and
    (implicitly) that the OP is very grateful to you. Why do you always
    have to be so explicit about matters? ;-)
    Because I'm not one of those Dutch people ;-)Yes, that's us, the Dutch: mysteriously smiling and keeping silent all the
    time. That's why they call us the Asians of Western Europe ;-)
    ps. There are nice exception to the rule sometimes though.
    Yes, and unfortunately they do seem to be the exception rather than
    the rule. It would be nice to catch one a bit more often.True; that's the internet generation: grab all the information that you can
    and don't give a f*ck about the guy who supplied the information. It's sad
    indeed.
    Maybe we should start a support group where we could thank each
    other now and then 'on behalf' of those little spoiled brats and complain
    about all those bad manners nowadays ;-)
    kind regards,
    Jos

  • JMS Appender in log4j.properties ??

    Hie Experts,
    I have setup a logging mechanism to log messages asynchronously using JMS queue.
    Currently, I am doing this as a call to a method.
    Inside the method, I am
    - creating a JNDI context,
    - retrieve queue connection factory,
    - create a queue session, create a queue sender and
    - associate to the retrieved queue.
    - Finally I send the message and close the queue.
    I do not think that this is the best strategy because:
    1. Queue gets initialized for all logging (making it slower)
    2. I believe that there must be a simpler way such as adding a JMS appender in log4j.properties
    Please advise if there is a better strategy.
    Thanks,
    V Chitkara

    Hi Vishal,
    You are correct in your assumption that there is a simpler way to perform logging using JMS.
    The Log4J project already contains a JMS appender. Take a look at this page:
    http://logging.apache.org/log4j/docs/manual.html
    And search it for "JMS".
    Hope this helps,
    Tom Jenkinson
    Arjuna Technologies Limited

  • Editing log4j.properties file of ear while deploying ear file.

    Hi,
    Can i edit log4j.properties file of ear while deploying ear file.
    ~ Dhiraj.

    javainstead:
    >>is MyFolder in the root? else you mite wanna try giving the entire path starting from the root
    No the "MyFolder" is not in the root. Normally if we give the file name alone, it will store in a directory. Instead of storing in that directory, i want to have create another subfolder under that directory and storing the file in it. This is my need.
    OS: Windows 2000.
    zakir_sh:
    log4j.rootCategory=DEBUG,myproj
    log4j.appender.myproj=org.apache.log4j.RollingFileAppender
    log4j.appender.myproj.File=/u3/logs/myproj_webapp_logs/dev_region/mylogfile.log......
    I gave relative path like this and got the file not found error.
    log4j.appender.myproj.File=/MyFolder/error_file.log
    Thanks,
    Manikandan

Maybe you are looking for

  • How can I transfer an e book from ADE to calibre and then to a sony ereader on a Mac

    Hi, I've read the past forums on this and I'm still having a real problem. I've got a Mac, my ADE is version 1.7 and my Sony reader is a 505. I can download an ebook into ADE but I can't get it into calibre to add it to my Sony, everytime I try an dr

  • Shortcut to SHUTDOWN no longer works

    I used to shut down my computer by punching COMMAND + EJECT, but ever since I updated to OS 10.4.9 yesterday, that feature no longer works. Any thoughts ???

  • Printing pdf files in a browser (e.g. Firefox) without opening the file

    I have a web application, which is generating pdf files. Is it possible to print a pdf file on the default printer without opening the pdf file? I want to click on the link of a pdf file and the file should be printed immediately on the default print

  • Problems with Associations between entities (jdev903production)

    Hi, every now and then, I feel a strong urge to pick up my pc and throw it out the window, when I'm working in jdeveloper. But usually just in time I realise the power that bc4j still has, and the fact that people walking under my window might not be

  • Field attributes in material master

    Hi, The field attributes maintained for material master; is showing the significant fields –‘material assignment’ (sales view) and ‘quantity structure’ (costing view) have been set as ‘optional’ at the time of updation.  Further, standard price can b