I think you can use Logger.getLogger("longMsg."+this.getClass().getName()) and  
then in the configuration file you have to do following setup:


<appender name="LONG_MSG" class="org.apache.log4j.FileAppender">
  <param name="Threshold" value="TRACE"/>
  <param name="File" value="${user.dir}/login_info.log"/>
  <layout class="org.apache.log4j.PatternLayout">
    <param name="ConversionPattern" value="%d{dd MM yyyy HH:mm:ss} %p %C %nIn 
Zeile Nummer: %L %m %n%n"/>
  </layout>
</appender>

<logger name="longMsg">
  <level value="trace"/>
  <appender-ref ref="LONG_MSG" />
</logger>
If it works for the long msg, you can do the same for short msg in the same 
file.
Thanks,
-OrkO

Beth Hechanova <[EMAIL PROTECTED]> wrote: Hi,

 

I have the concept of a long error message and a short error message in
my application.  Long error messages get written to one file, and the
short messages get written to a different file.  Ideally in my
application everywhere that needs to log an error message can simply
call Logger.getLogger(this.getClass().getName()).error(longMessage,
shortMessage) and the configuration of log4j will send the longMessage
and shortMessage to the appropriate file.

 

I have two different appenders configured for writing to the two
different files in the appropriate format.  But I don't know how to get
the long error message written only to one of the log files, and the
short error message only written to a different log file.

 

Is there a way to configure the properties file to accomplish this?  

Or would I need to extend the behavior in log4j itself?  If so, where
would be the place to extend the behavior?

 

Thanks,

Beth


Reply via email to