Re: How to filter specific characters to not to log

2006-09-20 Thread Bender Heri
A common way to enter binary data in xml is

- use base64 encoding  (not readable for humans, size is one third bigger than 
original)
- translate to hex string (readable for humans, size is twice as big than 
original)

Heri

 -Original Message-
 From: Praveen Kumar Hasthalapuram [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, September 19, 2006 8:03 PM
 To: Log4J Users List
 Subject: [SPAM (Bayesain Analysis)] - Re: How to filter specific
 characters to not to log - Bayesian Filter detected spam
 
 
 Hi Curt,
 
 We are facing problems with this chatacter  #0; issue,
 
 Is there any standard convention for representing a character 
 of value 0 in
 XML
 (and other control characters)?  I understand that we can't 
 actually *have*
 such a character - that's why #0; is illegal - but sometimes 
 we want to
 output
 data that includes such characters.
 
 or How to escape these characters in xml report.
 
 Regards,
 Praveen
 
 
 On 9/19/06, Curt Arnold [EMAIL PROTECTED] wrote:
 
  XMLLayout in both 1.2 and 1.3 can produce bad XML in several
  scenarios as reported in bugs 29244, 34875 and 37560.  
 Since I was an
  XML guru in a former life, I know of additional holes in the
  implementation.  If you'd be interested in testing it, I 
 could take a
  shot at re-implementing XMLLayout.  I think that would be a better
  solution than trying to filter content to avoid the bugs.
 
  On Sep 18, 2006, at 1:09 PM, Praveen Kumar Hasthalapuram wrote:
 
   Hi,
  
   We will get these characters from the devices and these data we
   will log.
   These logged data will be used to generate xml reports. With some
   devices
   we are getting some control characters (some spl symbols) 
 and these
   are
   causing xml report to fail. Is it possible to strip this 
 characters or
   filter this types of characters.
  
   Regards,
   Praveen
  
 
 
  
 -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: problem with alternative log4j.properties-file

2006-09-20 Thread Bender Heri
1. It is not recommended to subclass Logger. It would be better to write a 
Wrapper if you have particular business rules to implement.
2. In order to analyze your problem you should provide more details: 
- original property file
- alternative property file
- name(s) of involved loggers
- Where do you call te code below?

Heri

 -Original Message-
 From: Paulicke Stephan (KISP 53)
 [mailto:[EMAIL PROTECTED]
 Sent: Wednesday, September 20, 2006 3:10 PM
 To: log4j-user@logging.apache.org
 Subject: [SPAM (Bayesain Analysis)] - problem with alternative
 log4j.properties-file - Bayesian Filter detected spam
 
 
 hi,
 i wote a small application (contained in a .jar-file) which also
 includes a log4j.properties file.
 i also wrote my own logger which depends on org.apache.log4j.Logger
 everthing works fine so far. i included a parameter to define an
 alternative log4j.properties file
 that should be used:
   logProps.load(new
 FileInputStream(logPropFile));
   
 PropertyConfigurator.configure(logProps);
 if i use this, the logfile will be empty. this was working before i
 created my own logger.
 any ideas?
 
 thanx in advance
 
 stephan
 

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Add appender programmatically after logger configured initially with PropertyConfigurator

2006-09-20 Thread Donna Johnson
Thank you for your response, Kamal.  I added a call to activateOptions()
on each appender, but that still does not work.  I set log4j.debug to
true, and I see debug trace for setting the configuration through the
logger_config.properties file, but there is no trace for the appenders
added in the code other than setting the file for the FileAppender -
which I see twice and I've included below:
 
log4j: setFile called: /home/djohnson/test.txt, true
log4j: setFile ended
log4j: setFile called: /home/djohnson/test.txt, true
log4j: setFile ended

Thank you so much for your help!  Here's the code after I added the call
to activateOptions():
 
 try { 

   PatternLayout layout;
   String loggerPropFile = properties.getProperty(ngl.config,null);
   String loggerName = properties.getProperty(ngl.logger.name, null);
   if (loggerPropFile != null)
   {
PropertyConfigurator.configure(loggerPropFile);
   }

   logger = Logger.getLogger(loggerName);
   
   Enumeration en = logger.getAllAppenders();
   int nbrOfAppenders = 0;
   while (en.hasMoreElements()) {
nbrOfAppenders++;
Object ap = en.nextElement();
   }
   if (nbrOfAppenders  1) {
  return;
   }
   try {
if (true.equals(properties
  .getProperty(ngl.console, false))) {
 layout = new PatternLayout(%d [%t] %-5p %m%n);
 ConsoleAppender cnslAppndr = new ConsoleAppender(layout);
 logger.addAppender(cnslAppndr);
 cnslAppndr.activateOptions();
}
   } catch (RuntimeException e) {
handleException(e);
   }

 

   try {
String logfile = properties.getProperty(ngl.logfile, null);
 if (logfile != null) {
 layout = new PatternLayout(%d [%t] %-5p %m%n);
 FileAppender fileAppender = new FileAppender(layout, logfile);
 logger.addAppender(fileAppender);
 fileAppender.activateOptions();
}
   } catch (RuntimeException e) {
handleException(e);
   }
  } catch (Exception ex) {
   handleException(ex);
  }




From: Kamal Ahmed [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, September 19, 2006 3:57 PM
To: Log4J Users List
Subject: RE: Add appender programmatically after logger configured
initially with PropertyConfigurator



Donna,

 

I think you have to call activateOptions() method on your Appenders.
Also what error message / debug trace are you getting?

Hope this helps.

 

-Kamal.

 



From: Donna Johnson [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, September 19, 2006 4:48 PM
To: log4j-user@logging.apache.org
Subject: Add appender programmatically after logger configured initially
with PropertyConfigurator

 

I am trying to add a couple of appenders to my logger in the code based
on flags in the application's properties file.  I configure the logger
with an appender in the logger.properties file initially and I want to
add appenders to that programmatically.  I add a console appender as
well as a file appender (based on the flags).  Nothing is being logged
to either the console or the file, even though the file is being
created.  Any help is very much appreciated!

 

Here is the logger.properties file:

 

# Logger for Errors/Debugging (Syslog)
log4j.logger.error=DEBUG, A1
log4j.appender.A1=org.apache.log4j.net.SyslogAppender
log4j.appender.A1.syslogHost=localhost
log4j.appender.A1.facility=LOCAL5
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%d [%t] %-5p %m%n 

# Logger for stats
log4j.logger.stats=INFO,A2
log4j.appender.A2=org.apache.log4j.RollingFileAppender
log4j.appender.A2.File=./cust/properties/stats
log4j.appender.A2.MaxFileSize=10MB
log4j.appender.A2.MaxBackupIndex=1
log4j.appender.A2.layout=org.apache.log4j.PatternLayout
log4j.appender.A2.layout.ConversionPattern=%d %m%n

 

Here is the application properties file:

 

# Log to console
ngl.console=true


# Log to local5 (Unix only)
ngl.syslog=localhost:local5


# Log to a disk file
ngl.logfile=./cust/properties/test.txt


# Logging level (can be DEBUG, INFO, WARN, ERROR, or CRITICAL|FATAL)
ngl.level=DEBUG


# Host name that will print out on each log line
ngl.hostname=localhost


# If true, writes abbreviated log header with only level and message
ngl.brief=false

 

ngl.config=./cust/properties/logger_config.properties

 

ngl.logger.name=error

 

 

Here is the actual code to initialize the logger:

 

  try {

   PatternLayout layout;
   String loggerPropFile = properties.getProperty(ngl.config,null);
   String loggerName = properties.getProperty(ngl.logger.name, null);
   if (loggerPropFile != null)
   {
PropertyConfigurator.configure(loggerPropFile);
   }

   logger = Logger.getLogger(loggerName);
   
   Enumeration en = logger.getAllAppenders();
   int nbrOfAppenders = 0;
   while (en.hasMoreElements()) {
nbrOfAppenders++;
Object ap = en.nextElement();
   }
   if (nbrOfAppenders  1) {
  return;
   }
   try {
if (true.equals(properties
  .getProperty(ngl.console, false))) {
 layout = new 

Re: log4j doesn't log files when weblogic is run as a windows service.

2006-09-20 Thread Mirza Abbas Raza
Sorry about the late reply. Got stuck in a task. My replies are:

1. We are using log4j 1.2.7. I don't see the directories being created. 
3. I put breakpoints in eclipse and check the log4j properties file being 
loaded. It is the right one. As advised, I set log4j.debug=true, it doesn't 
help. I don't find the logs being written either to the console or to the 
files. :(


- Original Message 
From: Jacob Kjome [EMAIL PROTECTED]
To: Log4J Users List log4j-user@logging.apache.org
Sent: Monday, September 18, 2006 2:24:38 PM
Subject: Re: log4j doesn't log files when weblogic is run as a windows service.


A few quesions/comments...

1.  What version of Log4j are you using?  I think at some point, there was a
feature implemented which allowed Log4j to create any needed directories.  This
hadn't been the case previously.  I think it got implemented maybe post 1.2.9,
but I'm not positive.  So, it might make sense that the directories got
created.

2.  Clearly Weblogic's service is setting the startup directory if you find your
directories being created under mydomain.

3.  Are you sure that log4j.properties is getting picked up?  Is it possible
some other config file is getting picked up?  If log4j finds log4j.xml, it will
be used in preference to log4j.properties.  Also, try setting log4j.debug=true. 
Maybe you'll see some extra output.  Add a console appender to make sure you see
this output.  It should turn up in Weblogic's console log file.


Jake

Quoting Mirza Abbas Raza [EMAIL PROTECTED]:

 So, Jake, here is what I did but didn't succeed.

 Excerpt from log4j.properties file.
 # Specify the R log file
 log4j.appender.R=org.apache.log4j.DailyRollingFileAppender
 log4j.appender.R.File=logs/node/mylog.log
 log4j.appender.DAILY.DatePattern='.'-MM-dd

 Scenario 1: Run as is.
 - checked C:\winnt\system32.
 - obviously no logs found.

 Scenario 2: Created directories logs/node in C:\winnt\system32.
 - stopped service and restarted.
 - no logs found in C:\winnt\system32\logs\node directory.

 Scenario 3: Changed log4j.appender.R.File=logs/node/mylog.log to
 D:\mydirectory\domains\mydomain/logs/node/mylog.log
 - stopped and restarted service.
 - no logs found  in D:\mydirectory\domains\mydomain/logs/node/mylog.log.

 I couldn't find a way to specify the startup directory with the weblogic
 utility or the Java Service Wrapper and hence couldn't test it. However, I
 saw an interesting point in the properties for the service.
 D:\mydirectory\domains\mydomain\wrapper.exe -s
 D:\mydirectory\domains\mydomain\conf\managedwrapper.conf. The logs/node
 directory is located in mydomain directory. Wouldn't this point the logs to
 the right directory?

 Thanks,
 Abbas


 - Original Message 
 From: Jacob Kjome [EMAIL PROTECTED]
 To: Log4J Users List log4j-user@logging.apache.org; Mirza Abbas Raza
 [EMAIL PROTECTED]
 Sent: Monday, September 18, 2006 11:57:20 AM
 Subject: Re: log4j doesn't log files when weblogic is run as a windows
 service.


 I'll bet they *do* get created.  You just don't know where to look.  What
 does
 your config look like?  Does it use relative paths to the files?  Keep in
 mind,
 relative paths are relative to the directory from which the JVM started.  So,
 if
 you start on the command line, the path in the config file is relative to the
 current directory in the command shell.

 OTOH, When you start up using a service, unless you define the startup
 directory, it will default to C:\WINDOWS\system32 (or the equivalent on
 your
 windows box).  Furthermore, if your path includes a directory name, such as
 ./logs/mylog.log, and said directory doesn't exist already under
 C:\WINDOWS\system32, then Log4j won't bother creating it for you.  You have
 to make sure it exists before Log4j can write to the location.

 Look into that and let us know what you find.

 Jake

 Quoting Mirza Abbas Raza [EMAIL PROTECTED]:

  All,
 
  The log4j framework doesn't seem to write to the logs when weblogic is run
 as
  windows service. As I understand, the two things needed for the log4j
  framework are:
  - log4j.jar in classpath
  - log4j.properties as -Dlog4j.configuration. It contains the necessary
  configuration for logging.
 
  Both of the above mentioned artifacts are found correctly configured in the
  utilities that were used to create the windows service. I have used both
 bea
  provided utility and Java Service Wrapper from Tanuki Software. When
 weblogic
  is started after the service installation, log files that were supposed to
 be
  created by log4j don't appear. The ironic part is that when weblogic is
  started manually, the log files do appear. Is there a known workaround for
  this scenario? I appreciate any help.
 
  Environment info:
  OS - Windows 2000 server
  JDK - 1.4.2
  Weblogic - 8.1
  log4j - 1.2.7
 
  Thanks,
  Abbas
 
 




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL