Log4j.properties in ear

I would like to use log4j in an ear with log4j.properties in the ear. Is there any way to do this with manifest classpath or otherwise?
TIA, Tom

"Mark Griffith" <[email protected]> wrote:
Tom:
If you are on 8.1 you can put it in EAR/APP-INF/classes. EAR's have
no
manifest CP, so it would have to be in the MF CP of each module. (Which
is
why we came up with EAR/APP-INF/classes.
Cheers
mbg
"tom" <[email protected]> wrote in message
news:3eb2ec89$[email protected]..
I would like to use log4j in an ear with log4j.properties in the ear.Is
there any way to do this with manifest classpath or otherwise?
TIA, Tom
I have put the log4j.properties in the jar file, and in the manifest file for
the jar file write the log4j jar file, the log4j jar file is then in the ear file

Similar Messages

  • 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

  • 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

  • Help to solve problem with packaging log4j in a EAR file

    Hi All
    i struggle hard to create a EAR composed of EJB JARs and WARs and the programs
    in these JARs and WARs use log4j to log msg. Because i want all J2EE apps to have
    their own version of log4j library, i package log4j.jar in the EAR file. Below
    is my EAR package structure
    EJB1.jar
    EJB2.jar
    SharedUtilities.jar
    log4j.jar
    log4j.properties
    WEBAPP1.war
    WEBAPP2.war
    META-INF/manifest.mf
    For both EJB1.jar and EJB2.jar's META-INF/manifest.mf, there is a below entries
    Manifest-Version: 1.0
    Class-Path: SharedUtilities.jar log4j.jar
    However, my program always hit below runtime error.
    [java] Caused by: javax.ejb.TransactionRolledbackLocalException: EJB Exception:
    : java.lang.NoClassDefFoundError: org/apache/log4j/PropertyConfigurator
    But the program in EJB1.jar and EJB2.jar seem to have no such problem in loading
    classes in SharedUtilities.jar. The problem can be eliminated if i put log4j.jar
    at system classpath. Can anybody provide me with info on how to package a log4j
    library within a EAR package ?
    In addition, where should i put the log4j.properties so that it will be at search
    path of log4j and automatically loaded by log4j lib
    regards
    Danny

    Hi Slava Imeshev
    I am a bit confused about your reply. As said, the log4j.jar was packaged in my
    ear file. If the log4j.jar was not packaged in ear file, how come the ejb classloader
    can locate it.
    Secondly, if log4j.jar is included in system classpath, the ejb also can load
    log4j classes by system classloader. No "NoClassDeffound" exception is thrown.
    regards
    dso
    "Slava Imeshev" <[email protected]> wrote:
    "dso" <[email protected]> wrote in message
    news:[email protected]...
    Hi Slava Imeshev
    thanks for your response. I am a bit confused about your answer.
    i can't understand why u said the classloader COULD loadorg/apache/log4j/PropertyConfigurator.
    According to the error msg, it said
    " java.lang.NoClassDefFoundError: org/apache/log4j/PropertyConfigurator".
    Seemingly,
    this class in log4j.jar could not be located. But as i said in lastquestion,
    i seemed to have properly
    edit the "META-INF/manifest.mf" in EJB1.jar and EJB2.jar to includelog4j.jar
    in "Class-path" attribute. And my EJB classes have no problem in loadingclasses
    in SharedUtilities.jar. Would u please elaborate on it in more details?
    Sure. NoClassDefFoundError means that a DEPENDING class
    can not be loaded. If the classloader were not able to load the class
    itself, it would give you ClassNotFoundException.
    Just make sure that you don't have the same packages in
    the ear and in the class path so that you don't have classes
    loaded by system classloader trying to load classes loaded
    by ejb classloaders.
    regards
    dso
    "Slava Imeshev" <[email protected]> wrote:
    First, this error means that classloader was able to load
    org/apache/log4j/PropertyConfigurator, but cold not load
    one of depending classes. I'd inspect the CLASSPATH
    to see if there are any log4 classes there.
    Second, you can package your log4.properties into
    log4.jar itself.
    Regards,
    Slava Imeshev
    "dso" <[email protected]> wrote in message
    news:[email protected]...
    Hi All
    i struggle hard to create a EAR composed of EJB JARs and WARs and
    the
    programs
    in these JARs and WARs use log4j to log msg. Because i want all
    J2EE
    apps
    to have
    their own version of log4j library, i package log4j.jar in the EARfile.
    Below
    is my EAR package structure
    EJB1.jar
    EJB2.jar
    SharedUtilities.jar
    log4j.jar
    log4j.properties
    WEBAPP1.war
    WEBAPP2.war
    META-INF/manifest.mf
    For both EJB1.jar and EJB2.jar's META-INF/manifest.mf, there is
    a below
    entries
    Manifest-Version: 1.0
    Class-Path: SharedUtilities.jar log4j.jar
    However, my program always hit below runtime error.
    [java] Caused by: javax.ejb.TransactionRolledbackLocalException:EJB
    Exception:
    : java.lang.NoClassDefFoundError: org/apache/log4j/PropertyConfigurator
    But the program in EJB1.jar and EJB2.jar seem to have no such problemin
    loading
    classes in SharedUtilities.jar. The problem can be eliminated if
    i
    put
    log4j.jar
    at system classpath. Can anybody provide me with info on how to
    package
    a
    log4j
    library within a EAR package ?
    In addition, where should i put the log4j.properties so that it
    will
    be at
    search
    path of log4j and automatically loaded by log4j lib
    regards
    Danny

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

  • 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

  • How to load log4j.properties

    how to load log4j.properties file in my java code ?
    i have put log4j.properties in c:\property\log4j.properties directory.
    how do i load this properties file ?

    Normally you don't have to load it explicitely at
    all. Just place it in your classpath and use log4j,
    it should be loaded automagically.so, at run time i should use
    java -classpath .;c:\property\log4j.properties;c:\log4j.jar; MyClass
    is this the syntax ?

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

  • 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

  • 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

  • Log4j.properties with OAF R12

    I am writing OAF R12 components that integrate/extend existing R12 pages.
    I need to deploy a log4j.properties file for logging. I have a dependent jar file that uses log4j. This file is usually placed on the classpath in WEB-INF/classes for a servlet application.
    Where should I place this log4j.properties file so that the OAF R12 container (oc4j) reads this file when processing. I tried to add it to the CLASSPATH. I edited orion_application_xml_1013.tmp and placed the log4j.properties in $JAVA_TOP and added lines for the <library path> as
    <library path="$JAVA_TOP/log4j.properties" /> or
    <library path="%s_javatop%/log4j.properties" />
    and restarted the server.
    However, the log file defined in log4j.properties is not created when running the OAF framework and exercising the integrated code that includes log4j logging.
    What is the best way to integrate this properties file?
    Thanks,
    Ken

    gday Ken --
    If you are OAF R12 wouldn't there be an Oracle standard for logging you should be using? I'd be asking the OAF team for more details.
    Then I'd ask whether using log4j is worth the extra effort over using the Java standard logging API -- the container itself is using Java standard logging API, for which we have the ability to dynamically adjust log levels, view the logs, etc.
    Here are some links to some notes I wrote up recently on using log4j with OC4J (and also using Java standard logging API) :
    http://buttso.blogspot.com/2007/09/directing-log-messages-into-oc4j.html
    http://buttso.blogspot.com/2007/09/directing-log4j-logs-into-oc4j-logging.html
    http://buttso.blogspot.com/2007/09/using-shared-libraries-to-configure.html
    -steve-

Maybe you are looking for

  • Lion will not install on a January 2008 Mac Pro (3.1)

    I have a January 2008 Mac Pro (version 3.1) and I'm trying to install Lion on one of the hard drives in the main chassis. It has consistently failed. I have tried: Reseating memory Reseathing hard drives Zap PRAM Reset SMC Downloaded 4 fresh copies o

  • Final Cut 5 - Won't recognize video files when I try to reconnect media

    Help! Somehow FCP5 no longer recognizes my clips as video files. The problem started when I transferred some clips to another drive so I could reformat my primary external drive. (It's new, and had been formatted for PC, and I felt I needed to reform

  • Xslt mapping - xsl if ?

    HI, can you explain me "how to use the xsl if function" ? My source is an ORDRSP Idoc and i want to use the following. IF E1EDP20 is existing then .... and IF E1EDP20/WMENG = 0 then ... anyway... is there an option to test the xslt mapping with XML s

  • Using BT vision in a second location

    I have two BT internet accounts at separate locations. I have BT vision on one account for one property, and both properties have BT phone and internet from the same online BT account and pay both the bills. Am I able to take the BT vision box from t

  • Another connection error post

    Hi, I've tried connecting with a friend through AIM and have received the same connection errors. I've multiple sent invitations and he's sent multiple invitations to chat but I can never get the chat to start. He's been able to use iChat with others