Re: Exception while Application run on CD/DVD

2007-05-24 Thread James Stauffer

Your config is probably setup to write a file to the CD which is read-only.

On 5/24/07, Laxmilal Menaria [EMAIL PROTECTED] wrote:

Hello everyone,

I am using Log4j for logging in my products. This is working fine on my hard
drive, all logging are works. But if copied my application on CD/DVD then
log4j gives exception, I want if log4j die then Application should works.

I am getting the following exception while running on CD/DVD;

log4j:ERROR setFile(null,true) call failed.
java.io.FileNotFoundException: Logs\MyInfo.log (Access is denied)
at java.io.FileOutputStream.openAppend(Native Method)
at java.io.FileOutputStream.init(Unknown Source)
at java.io.FileOutputStream.init(Unknown Source)
at org.apache.log4j.r.a(Unknown Source)
at org.apache.log4j.r.f(Unknown Source)
at org.apache.log4j.s.f(Unknown Source)
at myapplication.ainit(Unknown Source)
at myapplication.main(Unknown Source)

Please suggest me..
--
Thanks,
Laxmilal menaria

http://www.minalyzer.com/
http://www.chambal.com/




--
James Staufferhttp://www.geocities.com/stauffer_james/
Are you good? Take the test at http://www.livingwaters.com/good/

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



Re: New Implementation: Logger-level Filtering

2007-05-24 Thread Brett Birschbach

As far as I know, log4j does not have a ForwardingAppender concept. 
However, implementing it is relatively trivial.  I actually rolled my own a
few months back trying to solve the problem of over filtering.  

In the end, a logger level filter still makes configuration MUCH more
straight forward, as well as providing a performance benefit.  Allow me to
explain the complexity and lower efficiency of the ForwardingAppender
approach:

=
A simple configuration is like you would expect:

  appender name=ROOT_APPENDER
class=com.X.log4j.appender.ForwardingAppender
 appender-ref ref=FILEAPPENDER/
 appender-ref ref=CONSOLEAPPENDER/
  /appender
  appender name=MY_FILTERED_APPENDER/
class=com.X.log4j.appender.ForwardingAppender 
 filter class=com.X.log4j.MyFilterForXYZDOSTUFF/
 appender-ref ref=ROOT_APPENDER/
  /appender

  logger name=com.xyz.dostuff additivity=false
 appender-ref ref=MY_FILTERED_APPENDER/
  /logger
  root
  appender-ref ref=ROOT_APPENDER/
  /root

On the surface the solution looks good.  However, let's say I want to add
another appender for all classes in com.xyz

  logger name=com.xyz additivity=true
 appender-ref ref=XYZFILE/
  /logger

Since, to prevent duplicate log entries, additivity=false for
com.xyz.dostuff, if I want the output from com.xyz.dostuff to go to XYZFILE
appender as well (since it is a subclass of com.xyz), now I need to add the
appender to com.xyz AND com.xyz.dostuff:

 logger name=com.xyz additivity=true
 appender-ref ref=NEW_COM_XYZ_APPENDER/
 /logger
 logger name=com.xyz.dostuff additivity=false
 appender-ref ref=NEW_COM_XYZ_APPENDER/
 appender-ref ref=MY_FILTERED_APPENDER/
 /logger

Not only am I duplicating appender references and creating ever increasing
complexity, but more importantly I have the same problems as originally.  I
have to filter both MY_FILTERED_APPENDER and NEW_COM_XYZ_APPENDER.  Instead
of just filtering log messages once, I have to filter them twice, once for
each appender.  Furthermore, instead of simply filtering log events from the
com.xyz.dostuff package, as I was before, now I am filtering all logging
events from all com.xyz.* packages due to filtering NEW_COM_XYZ_APPENDER.
===

As I state before, a Logger filter is still simpler and more efficient.




Ron Grabowski wrote:
 
 
 In log4net we have a ForwardingAppender that takes a message and fowards
 it to one or more other appenders. To solve the problem of not having to
 apply filters twice I'd put a ForwardingAppender infront of the two other
 appenders. If the message passed through the filters on the
 FowardingAppender the message would be sent to the registered appenders
 (in your example that would be a file and console). Is there something
 equivalent to a ForwardingAppender in log4j?
 
 


-- 
View this message in context: 
http://www.nabble.com/New-Implementation%3A-Logger-level-Filtering-tf3784606.html#a10795743
Sent from the Log4j - Users mailing list archive at Nabble.com.


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