Re: Verification of log4j configuration file

2011-08-12 Thread Antonio Rodriges
Thank you, Josef, very detailed explanation!

-
To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-user-h...@logging.apache.org



AW: Re: Verification of log4j configuration file

2011-08-09 Thread Stadelmann Josef
Hi Antonio

I suggest to you the following. 
1. Take NetBeans or any other IDE and catch the log4j open sources as a project.
2. Build log4j yourself, 
3. JDK 6.0,  maven 2.2.1 and ant 1.7 and a few other lesser important things is 
all you need
4. Do BUILD using NetBeans. / you can use also from a dos window mvn install 
comand
5. Select build.xml and ask for the javadoc ANT target to get doc and API's 
built
6. Then start your TrowableProperty or DOMConfiguratir development



basically you have to consider a few Configurators

BasicConfigurator
Is extended by the 
PropertyConfigurator(reading config data 
from a property file)
OR
DOMConfigurator (reading config data from a XML 
file)
Either of the two can be extended by your own 
TrowablePropertyConfigurator
OR
TrowableDOMConfigurator


You may develop your own TrowablePropertyConfigurator or 
TrowableDOMConfigurator and engage it as shown in the Java Class below but this 
time inside a try catch block.

So where is your TrowablePropertyConfigurator engaged?


Look at the file Log4JTest.java written by ThomasFenner under
./contribs/ThomasFenner  (here included as reference) 

You can see that this test catches exceptions if drives are not installed? OK?
And you can see which and how the PropertyConfigurator is engaged?

Now, at this stage we would engage your own TrowablePropertyConfigurator or 
your own TrowableDOMConfigurator



import org.apache.log4j.*;
import java.sql.*;
import java.lang.*;
import java.util.*;

public class Log4JTest
{
// Create a category instance for this class
   static Category cat = Category.getInstance(Log4JTest.class.getName());

   public static void main(String[] args)
   {
  // Ensure to have all necessary drivers installed !
try
  {
Driver d = 
(Driver)(Class.forName("oracle.jdbc.driver.OracleDriver").newInstance());
DriverManager.registerDriver(d);
  }
  catch(Exception e){}

  // Set the priority which messages have to be logged
cat.setPriority(Priority.INFO);

 try 
 {
// Configuration with configuration-file
//PropertyConfigurator.configure("log4jtestprops.txt");
TrowablePropertyConfigurator.configure("log4jtestprops.txt");
  }
  catch(Exception e){}  

  // These messages with Priority >= setted priority will be logged to the 
database.
cat.debug("debug");  //this not, because Priority DEBUG is less 
than INFO
  cat.info("info");
  cat.error("error");
  cat.fatal("fatal");
   }
}



For further understanding:
Go to the ./docs/api/org(apache/log4j/PropertyConfigurator.html
Open this and study what the PropertyConfigurator does for you?
And you will find you confirmed that no exceptions are raise by log4j's 
PropertyConfigurator for whatever reason. 
Can you extend the PropertyConfigurator and extend and implement 
TrowablePropertyConfigurator ! Certainly you can.

Finally do not forget to ask somebody from the developers group to help you 
check in your working/tested source code.

Maybe somebody more know to the subject can comment my suggestions

Josef



-Ursprüngliche Nachricht-
Von: Antonio Rodriges [mailto:antonio@gmail.com] 
Gesendet: Montag, 8. August 2011 11:05
An: log4j-user@logging.apache.org
Betreff: Re: Re: Verification of log4j configuration file

Thank you, Josef,

however I would like to force log4j return me an error code or throw
an exception (however docs says it never throws anything) in case of a
malformed config file to stop my application. Otherwise all logs will
cause exceptions and will not appear anywhere.
What is the best practice for an application to behave in case of
malformed log4j conf file?

-
To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-user-h...@logging.apache.org


-
To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-user-h...@logging.apache.org



Re: Re: Verification of log4j configuration file

2011-08-08 Thread Antonio Rodriges
Thank you, Josef,

however I would like to force log4j return me an error code or throw
an exception (however docs says it never throws anything) in case of a
malformed config file to stop my application. Otherwise all logs will
cause exceptions and will not appear anywhere.
What is the best practice for an application to behave in case of
malformed log4j conf file?

-
To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-user-h...@logging.apache.org



AW: Verification of log4j configuration file

2011-08-08 Thread Stadelmann Josef
Add as first line 
log4j.debug=true
to your config file and see how well your config file gets parsed
Josef

-Ursprüngliche Nachricht-
Von: Antonio Rodriges [mailto:antonio@gmail.com] 
Gesendet: Samstag, 6. August 2011 11:49
An: log4j-user@logging.apache.org
Betreff: Verification of log4j configuration file

Hello,

How to verify log4j configuration file to find out whether it is
malformed or not?
Can log4j notify me of bad file format?

Thanks

-
To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-user-h...@logging.apache.org


-
To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-user-h...@logging.apache.org



Verification of log4j configuration file

2011-08-06 Thread Antonio Rodriges
Hello,

How to verify log4j configuration file to find out whether it is
malformed or not?
Can log4j notify me of bad file format?

Thanks

-
To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-user-h...@logging.apache.org