Log4J: Different config files for different applications?

Hi all.
If you run an application which uses Log4J logging it's enough to place the log4j.xml file in the Classpath.
But how do you specify which configuration file to use during startup of a Java programm if they need different configurations but have the same classpath?
Thanks in advance
Carsten

my log4j knowledge is a bit outdated - but somewhere in your apps you should have a line that loads the properties file, something like:PropertyConfigurator.configure(path_to_log4j.properties);And the log4j.properties file should be in your app's EAR file somewhere - and since the app server creates a context for each application, I don't think there would be any "bleed over". So, does your setup differ from this somehow?
Good Luck
Lee

Similar Messages

  • Java.util.logging - different log files for different loggers

    I'm having trouble configuring Java logging to use different log files for different loggers.
    In log4j, I would do this by configuring multiple loggers each with a different appender. But how can I do this with Java (java.util.logging) logging?
    This is the basic idea of what I'd like to do:
    com.mycompany.app1.level = FINEST
    com.mycompany.app1.<log file> = logfile1.log
    com.mycompany.app2.level = ALL
    com.mycompany.app2.<log file> = logfile2.log
    Any suggestions?

    This kind of thing?
    import java.io.IOException;
    import java.util.logging.FileHandler;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    import java.util.logging.SimpleFormatter;
    public class LogTest {
        private Logger app1;
        private Logger app2;
        public LogTest() {
            // setup loggers
            try {
                // first logger
                app1 = Logger.getLogger("com.mycompany.app1");
                FileHandler filehandler = new FileHandler( "logfile1.log" );
                filehandler.setFormatter(new SimpleFormatter());
                app1.addHandler(filehandler);  
                // second logger       
                app2 = Logger.getLogger("com.mycompany.app2");
                filehandler = new FileHandler( "logfile2.log" );
                filehandler.setFormatter(new SimpleFormatter());
                app2.addHandler(filehandler);  
            } catch(IOException ioex) {
                ioex.printStackTrace();
        private void logStuff() {
            app1.log(Level.SEVERE, "a message for log 1");
            app2.log(Level.SEVERE, "a message for log 2");
            app2.log(Level.WARNING, "another message for log 2");
         * @param args
        public static void main(String[] args) {
            new LogTest().logStuff();
    }

  • So how to specify different answer file for different install images in WDS snap-in?

    hello
    in WDS snap-in, in properties on server name, on client tab, we can define an answer file for unattended windows installation on WDS clients.
    my question is, maybe we have added multiple images in WDS snap-in (win xp image, win 7 , win 2008,...)
    now this one answer file applies to all of them ?
    so how to specify different answer file for different install images in WDS snap-in?
    thanks in advanced 

    Under the "Client" tab of WDS, you should only use an answer-file with settings relevant for the installation. This would be credentials for the WDS deployment share, international settings used during the setup and possibly also destination drive
    details (if you want the installation to take care of partitioning the disk etc). The settings relevant for unattend-files used under "Client" would only be of those in phase 1 (WinPE).
    However, if you would like to have specific unattend file for every installation, e.g. Win7, Server 2008, Win 8 etc, you can browse to the image under "Install Images" under the image Groups. There you can select properties for every image and
    have a personal unattend-file.
    hi Joel
    very cool. thanks a lot, that really helped me.
    best regards

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

  • How to specify a different config file for a weblogic 6.1 server

    Hi,
    I have 2 weblogic startup scripts (startWebLogic.sh and
    startWebLogic_recovery.sh) for the same domain.
    startWebLogic.sh uses config.xml file.
    I would like to use config_recovery.xml as the configuration file for startWebLogic_recovery.sh
    How would I do this ?
    I am using WebLogic Server 6.1 on SunOS 5.8 / HP-UX 11.0.
    Appreciate any help.
    Regards
    Gunaseelan Venkateswaran

    Hello Gunaseelan,
    This is not possible because WLS 6.1 needs a config.xml file, exactly this
    name, to start.
    What you can do is to define a recovery domain, called myrecovery_domain for
    instance, and put the config_recovery.xml, renamed "config.xml".
    Hope this helps,
    Ludovic.
    Developer Relations Engineer
    BEA Support.
    "Gunaseelan Venkateswaran" <[email protected]> a écrit dans le message
    news: 3cd6a324$[email protected]..
    >
    Hi,
    I have 2 weblogic startup scripts (startWebLogic.sh and
    startWebLogic_recovery.sh) for the same domain.
    startWebLogic.sh uses config.xml file.
    I would like to use config_recovery.xml as the configuration file forstartWebLogic_recovery.sh
    >
    >
    How would I do this ?
    I am using WebLogic Server 6.1 on SunOS 5.8 / HP-UX 11.0.
    Appreciate any help.
    Regards
    Gunaseelan Venkateswaran

  • How to create different log files for different levels

    Hi,
    Can some one please help me with my problem I have here?
    I want to send log data to two diffrent files depending on the logging level such as DEBUG and WARN using the same logger instance.
    How can you configure this in log4j.properties.
    Please post sample code for log4j.properties to achieve this.
    Thanks in advance.
    Anurag SIngh

    Hi,
    I have tried your code. the issue is other log file for error is blank. its not writting log to that file.
    following is the code of my log4j.properties
    Please read the code first
    # Set root logger level to DEBUG and its only appender to A1.
    log4j.rootCategory=DEBUG,A1
    #Appender and its layout for A1
    log4j.appender.A1=org.apache.log4j.FileAppender
    log4j.appender.A1.layout=org.apache.log4j.PatternLayout
    log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %log4j.appender.A1.Threshold=DEBUG
    log4j.appender.A1.File=./LogonApplication_Debug.log
    log4j.appender.A1.Append=true
    #Appender and its layout for A2
    log4j.appender.A2=org.apache.log4j.FileAppender
    log4j.appender.A2.layout=org.apache.log4j.PatternLayout
    log4j.appender.A2.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %
    log4j.appender.A2.Threshold=ERROR
    log4j.appender.A2.File=./LogonApplication_Error.log
    log4j.appender.A2.Append=true
    In my logger class i have written something like this:
    public static Logger myLogger = Logger.getLogger (LoggerTest.class.getName());
         public static void main(String args[]){
              myLogger.debug("I have logged a debug message");
              myLogger.error("I have logged an error message");
    Issue:
    Now the problem is that it is creating two files specified in the configuration but it is logging messages both the messages debug and error in only ./LogonApplication_Debug.log file.
    Though it is creating the ./LogonApplication_Error.log file, but it is only blank.
    Can you please trace whats missing/wrong.
    Thanks a lot.
    Shanu

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

  • Webservice client : different wsdl file for test/production environment

    In an ADF application, I need call a web service in model project
    In my company, we have 2 environments : test and production.
    This webservice is deploye in test server and production server.
    So there are 2 different wsdl file for test/production.
    I want to make my ADF Application portable cross the 2 environments.
    An environment variable can indicate in which environment the ADF application run.
    According to this variable, application choose which wsdl/endpoint to call.
    If I use "web service Data control" wizard, how can I achieve this?
    If I use "webservice proxy" wizard, how can I achieve this?
    Thanks!!!!!!

    Hi,
    I have a model project with ws proxy client and on this proxy I added an adf ws connection called CustomerExperience
    then I can do this.
    // a test to try to overrule the adf ws connection from EM
    Context ctx = null;
    try {
    ctx = ADFContext.getCurrent().getConnectionsContext();
    WebServiceConnection wsc = (WebServiceConnection) ctx.lookup("CustomerExperience");
    CustomerExperience customerExperience = wsc.getJaxWSPort(CustomerExperience.class);
    } catch (NamingException e) {
    LOGGER.severe("got web service loading fault: "+ e.getMessage());
    throw new JboException( messages.getString("NOM-999"),
    "NOM-999",
    null );
    I exported this to an adf jar and added this to a webapp.
    On runtime the ws connection is not dectected by the webapp so need to copy this ws conn to the connections of the webapp. This works
    but can I change it from wlst instead of EM , is this possible?
    I don't see the WS connection in wlst (oracle common) adf_listURLConnection('CE_Portal')
    thanks

  • Ldt files for different templates have same data

    i was asked to get .ldt files for different templates. I used FNDLOAD to download the files using xdotmpl.lct file. all the .ldt file when open in text has the same data. Am I doing something wrong. If the files are same why do we need seperate .ldt file for each template.

    But if you developing something and you are going to version it, then
    In case of single LDT
    ==================
    Its easy as you said, we can down load all def into one file.
    But, if one of the template def. got changed, all data gets downloaded unnecessarily .
    Single file , so you can say its easy .
    In case of multiple LDT
    ==================
    But, if one of the template def. got changed, then download that one only into ldt.
    Multiple file , little more effort is needed to create them.
    But more easy to maintain,

  • Multiple log4j.xml files for single application.

    Hi All,
    How to use multiple log4j.xml files for single application?
    I do have a pluggable application modules. ie, If I add a jar I will get some functionalities. Like that i do have many jars.
    Log4j.xml also will be present in that jar only. So if I add multiple jar files like this, I will get multiple log4j.xml files. What should I do?

    Each logger can have its own file I think. Check the log4j documentation.

  • Different WAR File for OSB and SOA Load Balancers on  Clustered Environment

    Hi,
    Do we need different proxyapp.war Files for each Load Balancer of SOA and OSB Respectively on a Clustered Environment?
    Thanks in Advance.

    Hi,
    Yes you need to have different .war file placed different server to have multiple load balancers.
    Regards,
    Kal

  • Optimizing captivate file for different screen resolution

    Hi,
    I've a problem in optmizing the captivate file for different screens like laptop,netbook and pc. In PC's and laptops, this is not a major issue as the size of the screen is large. But when we play the captivate generated swf file in a netbook, the whole website gets resized to fit in to the resolution of the screen except the captivate file.Captivate file gets truncated in such a way that, the user can read only half of the slide.
    Thanks in advance
    Parvathy

    One thing you can try is adjusting the swf dimensions manually.  I haven't found a way to do it in Cp.  We had a similar problem with some eLearning we built that all our testers used just fine.  But once someone undocked their laptop and was off their desktop monitor, had the same problem you describe, where the bottom of the movie was cut off.
    Once you publish the files, open the .htm file with notepad or your text/html editor of choice.
    Look for a line that looks something like this:
    var so = new SWFObject(strURLFile + strURLParams, "Captivate", "1100", "798", "10", "#CCCCCC");
    or
    var so = new SWFObject("filename.swf", "Captivate", "1600", "1200", "10", "#CCCCCC");
    Change those numbers in quotes to 100%, like this:
    var so = new SWFObject("filename.swf", "Captivate", "100%", "100%", "10", "#CCCCCC");
    save the .htm
    My experience has been it will adjust the swf so it fits either the height or width of the display, whichever is shorter.  That is, it will either fill the top to bottom OR side to side, but keep the swf in proportion.
    hope that helps.

  • How to set two different welcome-file to different servlets in web.xml

    Hi friends,
    Can some one help with web.xml file
    I have to different servlets in applications.
    I want to set two different welcome files for my two different
    servlets in web.xml
    Please, can some one give me sample code to achieve this.
    Here web.xml code:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <!DOCTYPE web-app PUBLIC
    "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/dtd/web-app_2_3.dtd">
    <web-app>     
         <servlet>
              <servlet-name>reports</servlet-name>
              <servlet-class>com.caremark.ivr.servlet.IvrReportsServlet</servlet-class>
         </servlet>
         <servlet-mapping>
              <servlet-name>reports</servlet-name>
              <url-pattern>/reports</url-pattern>
         </servlet-mapping>
         <session-config>
              <session-timeout>30</session-timeout>
         </session-config>
         <welcome-file-list>
              <welcome-file>reportsindex.jsp</welcome-file>
         </welcome-file-list>
         <servlet>
              <servlet-name>calldetails</servlet-name>
              <servlet-class>com.caremark.ivr.servlet.IvrCallDetailsServlet</servlet-class>
         </servlet>
         <servlet-mapping>
              <servlet-name>calldetails</servlet-name>
              <url-pattern>/calldetails</url-pattern>
         </servlet-mapping>
    <welcome-file-list>
              <welcome-file>calldetailsindex.jsp</welcome-file>
         </welcome-file-list>
    </web-app>
    I need this fix immediately. Your help will be really appreciated. Thanks in advance.

    First of all, my understanding is that you need to have a Servlet 2.4 complaint server to do this...Given that, you're supposed to be able to simply specify the Name of the servlet as the welcome-file to get it to work. For example:
    Your servlet section:
    <servlet>
      <servlet-name>Controller</servlet-name>
      <servlet-class>com.company.ControllerServlet</servlet-class>
    </servlet>Now you would add the following to your welcome file list:
    <welcome-file-list>
      <welcome-file>Controller</welcome-file>
    </welcome-file-list>Note that you use the servlet-name value from the servlet definition, NOT the url-mapping from the servlet-mapping section.
    Please note that I cannot verify this as I am running a 2.3 server at home. When I get to work Friday I can test on a 2.4 machine. However this shouldn't take you more than a minute to test.
    Note that I did try this on the 2.3 compliant server and it did NOT work (as I expected)...
    HTH.

  • How to build ear files for ADF application using Ant task

    How to build ear files for ADF applications using Ant. The ojdeploy ant task can not find application-level deployment profiles. I am trying to automated build and release for ADF application.
    Any help is highly appreciated.
    Thanks
    Shiva

    Hi Timo
    Thanks for your reply.
    I have successfully created ear file using ojdeploy on jenkins. however when am trying to auto deploy using WLDeploy ant task am getting the following
    error :
    weblogic.application.ModuleException: :oracle.mds.config.MDSConfigurationException:MDS-01335: namespace "/oracle/webcenter/quicklinks/scopedMD" mapped to metadata-store-usage "WebCenterFileMetadataStore" but its definition was not found in MDS configuration
    Please advise how to handle this.
    As am a newbie to ADF, could you please advise if it is possible for the ADF application deployments can be automated for different environments using jenkins due to this MDS dependencies.
    Appreciate your help.
    Thanks
    Shiva

  • Where are files for my applications kept? I'm trying to do a clean install.

    I have an intel imac OS 10.6.8. I have to do a clean install and need to transfer my files to a USB flashdrive because time machine hasn't backed up in 3 months. Where are files for my applications kept?

    Since you mentioned Time Machine, I'm assuming you have an external hard drive? So why not make a complete backup - either with Time Machine or a bootable clone with CarbonCopyCloner or SuperSuper? Applications sometimes transfer well, but not always - it depends how many files/parts they have on the hard drive in different locations. There is no simple answer to your question because of that - it depends on the individual application. I'd back up all of it, do the install, and then use Setup Assistant to port things back.

Maybe you are looking for