[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

5.0

log4j - XML config logging for my package

Asked by rstaveley in Jakarta Struts, Java Programming Language, J2EE

Tags: log4j, xml

My package is com.mycompany.mypackage - i.e. classes are com.mycompany.MyClass etc. I'd like to log INFO from my package in a dedicated log file, using log4j. I need to use the XML configuration for reasons beyond the scope of this question.

I thought I could set it up thus:

--------8<--------
<?xml version="1.0" encoding= "UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">

      <appender name="stdout" class="org.apache.log4j.ConsoleAppender">
            <layout class="org.apache.log4j.PatternLayout">
                  <param name="ConversionPattern" value="%d %p [%c] - &lt;%m&gt;%n"/>
            </layout>
      </appender>

      <appender name="logfile" class="org.apache.log4j.RollingFileAppender">

            <param name="Threshold" value="DEBUG"/>
            <param name="Append" value="true"/>
            <param name="MaxFileSize" value="512KB"/>
            <param name="MaxBackupIndex" value="5"/>
            <param name="ImmediateFlush" value="true"/>

            <!-- file parameter is taken from the XML fragment, which is environment-specific -->
            <param name="File" value="mypackage.log"/>

            <layout class="org.apache.log4j.PatternLayout">
                  <param name="ConversionPattern" value="%d %p [%c] - %m%n"/>
            </layout>
      </appender>

      <logger name="com.mycompany.mypackage">
            <level value="info"/>
            <appender-ref ref="logfile"/>
            <appender-ref ref="stdout"/>
      </logger>

      <root>
            <priority value="warn"/>
            <appender-ref ref="stdout"/>
      </root>

</log4j:configuration>
--------8<--------

However, I don't get enything going into my log file. It remains 0 bytes.

Here's how I initialise the logger in my class:
--------8<--------
package com.mycompany.mypackage;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

pubic class MyClass {

    static final Log log = LogFactory.getLog(MyClass.class);

    // ....
}
--------8<--------

What am I doing wrong?
 
Related Solutions
Keywords: log4j - XML config logging for my pac…
 
Loading Advertisement...
 
[+][-]08/25/07 08:08 AM, ID: 19768125Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08/27/07 10:00 AM, ID: 19776731Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08/28/07 12:46 AM, ID: 19781024Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08/28/07 05:42 AM, ID: 19782329Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08/28/07 05:55 AM, ID: 19782424Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08/28/07 06:03 AM, ID: 19782498Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08/28/07 06:19 AM, ID: 19782660Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08/28/07 07:02 AM, ID: 19783069Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08/29/07 02:23 AM, ID: 19789712Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08/29/07 06:35 AM, ID: 19791032Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08/29/07 10:24 AM, ID: 19793371Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08/29/07 10:32 AM, ID: 19793422Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08/29/07 12:07 PM, ID: 19794327Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zones: Jakarta Struts, Java Programming Language, J2EE
Tags: log4j, xml
Sign Up Now!
Solution Provided By: jim_cakalic
Participating Experts: 2
Solution Grade: A
 
[+][-]08/29/07 12:15 PM, ID: 19794414Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08/29/07 12:45 PM, ID: 19794714Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08/29/07 02:57 PM, ID: 19795818Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08/29/07 11:08 PM, ID: 19797775Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08/30/07 05:02 AM, ID: 19799188Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08/30/07 05:06 AM, ID: 19799211Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08/30/07 05:08 AM, ID: 19799228Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08/30/07 05:12 AM, ID: 19799252Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08/30/07 05:33 AM, ID: 19799399Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08/30/07 05:39 AM, ID: 19799448Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08/30/07 05:42 AM, ID: 19799472Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08/30/07 05:56 AM, ID: 19799572Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08/30/07 05:58 AM, ID: 19799592Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-89 / EE_QW_1_20070628