Log4j for individual classes

Hi,
I defined a log4j.properties file in my class directory:
log4j.defaultInitOverride=false
log4j.rootLogger=DEBUG, R, S
log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=R.log
log4j.appender.R.MaxFileSize=100KB
log4j.appender.R.MaxBackupIndex=0
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%p %t %c - %m%n
log4j.appender.S=org.apache.log4j.RollingFileAppender
log4j.appender.S.File=S.log
log4j.appender.S.MaxFileSize=100KB
log4j.appender.S.MaxBackupIndex=0
log4j.appender.S.layout=org.apache.log4j.PatternLayout
log4j.appender.S.layout.ConversionPattern=%p %t %c - %m%n
Then I used the Logger in loginAction.java:
private Logger logger = Logger.getLogger("R");
logger.setAdditivity(false);
logger.info("LoginAction");
and in OracleDAOFactory.java:
private Logger logger = Logger.getLogger("S");
logger.setAdditivity(false);
logger.info("Connected to DB from customer DAO");
what I want to achieve is to record the information for loginAction in R.log and record the information for OracleDAOFactory in S.log. But do NOT accumulate loginAction's information into OracleDAOFactory, and vice versa.
The above codes work properly if I remove the line "logger.setAdditivity(false);". The result is both log files have the contents. But if I add the line "logger.setAdditivity(false);", I get the following error message:
log4j:WARN No appenders could be found for logger (S).
log4j:WARN Please initialize the log4j system properly.
What is wrong with my above coding?
Thanks for your help!
Message was edited by:
[email protected]
Message was edited by:
[email protected]

http://forums.java.net/jive/thread.jspa?threadID=75990&tstart=0

Similar Messages

  • Multiple HTTP GET requests for individual classes

    Hello,
    I have a Java plug-in deployed under tomcat 6. JRE version is 1.6.0_16. All the required jars are deployed packed (pack.gz) and the applet tag has 'java_arguments' parameter defined as:
    <param name='java_arguments' value='-Xms256m -Xmx512m -Djnlp.packEnabled=true -Djnlp.versionEnabled=true' />
    All the jars get loaded nicely as I see in the Tomcat access log:
    127.0.0.1 - - [03/Mar/2010:17:24:04 +0000] "GET /testapplet/lib/log4j-1.2.13.jar.pack.gz?version-id=1.2.13 HTTP/1.1" 200 0
    but immediately I see a bunch of GET requests for the individual classes in the same log4j jar:
    127.0.0.1 - - [03/Mar/2010:17:24:06 +0000] "GET /testapplet/lib/org/apache/log4j/Logger.class HTTP/1.1" 404 0
    127.0.0.1 - - [03/Mar/2010:17:24:06 +0000] "GET /testapplet/lib/org/apache/log4j/Category.class HTTP/1.1" 404 0
    127.0.0.1 - - [03/Mar/2010:17:24:06 +0000] "GET /testapplet/lib/org/apache/log4j/spi/AppenderAttachable.class HTTP/1.1" 404 0
    As you can see each of these GET requests are returned a Http error code 404. While testing locally, this isn't adding any delays, but over a real deployment it's bound to be slow down the applet loading while the server is responding to each of these class requests.
    Subsequently, the application itself runs without any issues and these bogus class requests failures have no effect (thankfully) on the functionality.
    Any one seen this behavior? Appreciate any thoughts or help.
    Regards,
    Parag

    http://forums.java.net/jive/thread.jspa?threadID=75990&tstart=0

  • Why does applet send individual class requests?

    I have a jnlp applet that takes too long to load. It's signed war file is about 16 Mb size. Server access log shows the jar files are loaded successfully, relatively quickly followed by a ton of http GET requests for individual class files. These resource requests are not successful and returns with http response 404 - like the following:
    "GET /examples/lib/org/apache/log4j/Logger.class HTTP/1.1" 404 1069
    Weird thing is, the applet runs fine. above 'missing' resources are referenced and used just fine and there are no 'ClassNotFound' exception anywhere.
    Is this a class loader issue where the browser loader first looks for the class file on server before peering into the jars it has already loaded? or any other thing I am possibly overlooking?
    browser VM: jdk1.6.0_10; server vm: jdk1.6.0_03.
    Appreciate your help.
    Parag
    Edited by: pgokhale on Apr 14, 2008 2:20 AM

    I have a jnlp applet that takes too long to load. It's signed war file is about 16 Mb size. Server access log shows the jar files are loaded successfully, relatively quickly followed by a ton of http GET requests for individual class files. These resource requests are not successful and returns with http response 404 - like the following:
    "GET /examples/lib/org/apache/log4j/Logger.class HTTP/1.1" 404 1069
    Weird thing is, the applet runs fine. above 'missing' resources are referenced and used just fine and there are no 'ClassNotFound' exception anywhere.
    Is this a class loader issue where the browser loader first looks for the class file on server before peering into the jars it has already loaded? or any other thing I am possibly overlooking?
    browser VM: jdk1.6.0_10; server vm: jdk1.6.0_03.
    Appreciate your help.
    Parag
    Edited by: pgokhale on Apr 14, 2008 2:20 AM

  • Why is U51 blocking individual class files not in jars but U45 accepted them?

    Let me answer the "why do you need individual class files?" question first. We have a rather large applet based application with a current client-side minimum jar download size of 1.8 MB. If we put ALL of our class files into jars, that size will probably double. Most users only use a small portion of the class files for their particular tasks. Which of the class files they use depends upon the tasks they perform. Having ALL users download ALL the classes, albeit compressed in jars, is extremely time consuming and a major problem after application updates due to the large number of users and the network load it would cause.
    Jar file manifest:
    Permissions: all-permissions
    Codebase: *
    Application-Name: MyApplication
    Application-Library-Allowable-Codebase: *
    Caller-Allowable-Codebase: *
    Trusted-Library: true
    We have 11 directories with one containing the applet and main client application code. The other 10 directories contain class files relating to the various sub-applications in the system. The system has a third-party runtime jar file, too.
    We have a private network and servers for our business so the exposure is small. This is a screen-scraping, reformattring application that does no real data processing so doesn't need the same security as a true data processing application. Since we are not open to the Internet and of limited security risk, we chose to keep a more simplified structure.
    This all worked under 1.7.0_45. I read the security guide and it was my understanding that these attributes in the manifest would also work for U51. Apparently not. Looking at the guides, now, it appears they have been changed sometime last year regarding mixed-code to mean jars with certificates and jars without certificates. The support for individual class files appears to have been removed. If this is true, then there should have been a beta of the U51 code because the rules seem to have been changed since the last release or there is a new bug.

    This is exactly my same problem. My app (and applet) is about 5 MB if I consider all the classes and libraries used by the app. (I mean 5MB is the size of the jar file). I can't ask customers to download 5 MB every time they want to access the program.
    We need java ask code signing for the principal applet but then we must have the possibility to run single class files as needed.
    Help us all please.
    Thanks Paolo

  • Enabling log4j for  a single class or package

    hi all
    If i use log4j for logging in my classes,
    is there a way for enabling it just for a single class or a packages?
    Considers that i use log4j.properties for configure it
    Regards
    Giovanni

    Two things. Firstly, it's better to use     private static final Object classLock = new Object();because that saves you worrying about whether any other code synchronises on it. Secondly, if you do decide to go for the delegation route then java.lang.reflect.Proxy may be a good way forward.

  • Central auto-reactions for individual MTEs, not entire MTE classes

    Hello.
    I am trying to set up central autoreactions on a Sol Man system (CEN) to monitor certain MTEs on a satellite system (soon to be many more satellite systems and other MTEs). I know that auto-reactions can be assigned to a satellite system and specific MTE class in RZ21 on CEN, but I don't want auto-reactions for every MTE in a specific class. For example, I want to monitor the percentage full for a specific file system, which has the class "FilesystemPercentageUsed", but there are many other MTEs in the parent "file systems" branch which also have the same class. I only want a central auto-reaction for the one--not all of the MTEs in that class.
    Has anyone else achieved this? If so, I'd love to hear your recommendations. Any help is appreciated!
    Thanks!

    Hello Matthew,
    central autoreaction is only possible for MTE classes.
    > For example, I want to monitor the percentage full for a specific file system, which has the class "FilesystemPercentageUsed", but there are many other MTEs in the parent "file systems" branch which also have the same class. I only want a central auto-reaction for the one--not all of the MTEs in that class.
    In this case: change the MTE class. As you use already agents (otherwise central autoreaction would not be possible) you can configure the agent to use MTE classes different to the default ones.
    The Online documentation for the agents describes this: [Monitoring Operating System Data with CCMS Agents|http://help.sap.com/erp2005_ehp_03/helpdata/EN/2b/6dcd06dc6b084a840f209e027e39b1/frameset.htm].
    Regards, Michael

  • 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

  • Configuring Log4j for a EJB Project.

    Hi,
    I have a weblogic EJB project as a Ear file. The project has no web components (so war file). I want to know which is the ideal way to initialize log4j in this situation.
    I can use listener class thro' weblogic-application.xml. But there is no neat way to passing the log4j.xml thro' parameter from weblogic-applicaiton.xml file.
    If we are using servlet we could use init-parm to passing xml file. I don't want to hard code the xml file location in the listener class.
    What is the best practice to initialize log4j for a EJB project?
    Thanks in advance.
    Anand

    Dan,
    I had a similar problem because I wanted to define my own log4j config regardless of what other portal apps were deployed in the BEA domain or what log4j was the default for the domain. This is what I do:
    1) Put your log4j config file in the WEB-INF classes dir (or I guess it could be in some other place that the CLASSPATH knows of)
    2) Create a servlet that looks like:
    import javax.servlet.*;
    import javax.servlet.http.*;
    import org.apache.log4j.xml.*;
    public class Log4jInitServlet extends HttpServlet {
    private static final long serialVersionUID = 23456;
    public void init(ServletConfig config) throws ServletException {
    super.init(config);
    DOMConfigurator.configure(Thread.currentThread().getContextClassLoader().getResource("myLog4jConfigFile.xml"));
    public void doGet(HttpServletRequest req, HttpServletResponse resp) {
    3) Add the servlet definition in the web.xml and add a <load-on-startup>1</load-on-startup>
    That should do it.
    - Peter

  • Adding ToolTip for individual cell in the table

    Hi everybody,
    Its urgent. I want to add ToolTip for individual cells. What I have implemented, it show same ToolTip for each cell. I want different ToolTip for individual cell.
    My cells are not editable, as i need this.
    Pleae help me.
    Thanks in Advance.
    Dawoodzai

    Hi,
    See this demo pasted below-
    import java.awt.*;
    import javax.swing.*;
    public class SimpleTableDemo extends JFrame {
         public SimpleTableDemo() {
              super("SimpleTableDemo");
              Object[][] data = {
                   {"Mary", "Campione", "Snowboarding", new Integer(5), new Boolean(false)},
                   {"Alison", "Huml", "Rowing", new Integer(3), new Boolean(true)},
                   {"Kathy", "Walrath", "Chasing toddlers", new Integer(2), new Boolean(false)},
                   {"Sharon", "Zakhour", "Speed reading", new Integer(20), new Boolean(true)},
                   {"Angela", "Lih", "Teaching high school", new Integer(4), new Boolean(false)}
              String[] columnNames = {"First Name", "Last Name", "Sport", "# of Years", "Vegetarian"};
              final JTable table = new MyTable(data, columnNames);
              table.setPreferredScrollableViewportSize(new Dimension(500, 70));
              JScrollPane scrollPane = new JScrollPane(table);
              getContentPane().add(scrollPane, BorderLayout.CENTER);
         public static void main(String[] args) {
              SimpleTableDemo frame = new SimpleTableDemo();
              frame.pack();
              frame.setVisible(true);
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class MyTable extends JTable {
         public MyTable(Object[][] rowData, Object[] columnNames) {
              super(rowData,columnNames);
         public String getToolTipText(MouseEvent e) {
              int r = rowAtPoint(e.getPoint());
              int c = columnAtPoint(e.getPoint());
              return getValueAt(r,c).toString();
    }

  • How to setForeground for individual JTable rows???

    How do you set the foreground and background colors for individual rows in a JTable? I don't want every row to change, just the rows I select programmatically (not via the GUI). The JTable.setForeground() from the JComponent base class changes all the rows. Any ideas?

    Hi!
    Write your own renderer and set it as defaultRenderer on your table. Something like this:
    // Using Object.class makes sure the renderer will be used regardless of column class type
    myTable.setDefaultRenderer(Object.class, new MyRenderer(Color.red));And the renderer:
    class MyRenderer extends javax.swing.table.DefaultTableCellRenderer
        private Color m_mySelectedColor;
        public MyRenderer(Color par_mySelectedColor)
            m_mySelectedColor = par_mySelectedColor;
        public Component getTableCellRendererComponent(JTable table,
                                                       Object value,
                                                       boolean isSelected,
                                                       boolean hasFocus,
                                                       int row,
                                                       int column)
            Component returnComponent = super.getTableCellRendererComponent(
                    table,value,isSelected,hasFocus,row,column);
            if (isSelected)
                returnComponent.setBackground(m_mySelectedColor);
            else
                returnComponent.setBackground(table.getBackground());
            return returnComponent;
    }smedman

  • Maximum no'of Objects for one class

    Hello friends
    Please, tell me....Maximum no'of Obects for One Java class.
    Thanks & Regards
    S.Rajakrishna

    Is there any limit of creating the objects for One class?Instantiated objects go into the heap. There is only one heap for the whole JVM. There is no correlation between objects in the heap and the individual class files.
    100,000 objects may or may not fit into the heap. In general they probably will. If you don't, then yes, you'll get an Out Of Memory exception.
    Regardless there is no excuse for loading 100,000 objects just to render a JSP! You don't imagine your user is going read all of them do you? Restrict them to the number of objects that the user is actually going to be able to handle at any given time.
    You can do this by putting WHERE clauses on the hibernate query, and/or by setting limits (setFirstResult and setMaxResult) on the Query object before listing it.

  • Configuring Log4j for weblogic

    Hi
    can any one tell me how to configure Log4j for weblogic. I have added the log4j jar files to the weblogic classpath but it does not seem to work..
    Thanks and Regards
    Narayan

    You must make a new directory on the same level with applications directory, place "log4j.properties" file in it, include this directory in the "PRE_CLASSPATH" entry in your startup script and that's all.
    Sample line in "startWebLogic.cmd" script
    'set PRE_CLASSPATH=%_LIBJARS%;classes'
    in classes dir you have "log4j.properties"
    Should work,
    Cristian Negoita

  • Use preloader for individual frames?

    I have followed this video on how to build a preloader and I was able to incorporate it into my own site.  Now, I'm wondering now how to build a preloader for individual frames.  For example, I have a link called "Videos" that, when clicked, jumps to frame 10.  This is where I have all the videos visible in the main content area of my site.  However, I'd like to add a preloader so that as the videos load, visitors can see the progress.  Is there a way I can reuse the preloader.swf file I have already built for individual frames of my main site?
    Here is the code for the preloader.swf file which consists of a single dynamic text field located in the center called preloaderTxt:
    var l:Loader = new Loader();
    l.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loop);
    l.contentLoaderInfo.addEventListener(Event.COMPLETE, done);
    l.load(new URLRequest("WebsiteTest.swf"));
    function loop(e:ProgressEvent):void
        var perc:Number = e.bytesLoaded / e.bytesTotal;
        preloaderTxt.text = Math.ceil(perc*100).toString() + "%";
    function done(e:Event):void
        removeChildAt(0);
        preloaderTxt = null;
        addChild(l);

    (1)Java class name should begin with a capital letter. See: http://java.sun.com/docs/codeconv/
            JButton save = new JButton("Save");
            JButton save2 = new JButton("Save and add another");
            // ... etc. ...(2)Don't redeclare class members in a method as its local variable. Your class members become eternally null, a hellish null.
    how to make them work when clicked on(3)Add action listener to them.

  • Error in Balances for Individual Assets Report

    Hi,
    We are trying to generate a report through transaction code S_ALR_87011978 (Balances for Individual Assets, Including Components of Group Assets). However, we are wondering why the result always  says "No Data Was Selected" whatever asset/asset class we put as a parameter. When I checked the list of assets per group asset there are no entries. Does this mean that this report is specifically for group asset balances which is why there is no data/output generated because we do not have a group asset? Please confirm. Thank you!

    Hi,
    You are right that S_ALR_87011978 is only for reporting group asset or asset belonging to a group and the number of asset group should be entered in the asset number input field in order to output the report. If your SAP asset accounting is not using group asset it explains why the result you have been getting.
    Kind regards,
    John Chin

  • Log4j for EJB3

    How can I configure log4j for ejb3? for example in jsf I create servlet listener initialize logger with some config file (defined in web.xml) and call
    it from my beans.
    private Logger log = null;
    constructor () {
    log = Logger.getLogger(MyRegister.class);
    }ho can i do this correctly only for EJB3?

    I think a better way of logging EJBs is the use of interceptor. This is the approach I use.
    Get a regular java class that offers logging services using log4j
    create a business interceptor for you EJB business services
    add the interceptor annotation to your EJBs with the class name for you interceptor.
    I think this approach is better so you don't mingle business code with utility code.
    thank God for interceptor.
    Regards.

Maybe you are looking for