Hi Jason, I only saw your question now. Yes it is indeed possible. I am attaching an example log4j configuration file which I am using to educate some of the guys on my team about log4j. I have not uploaded the source of the presentation that goes along with the config file to sourceforge yet as I am still busy setting up the whole presentation. But this file should help some at least. If you are interested I will notify you once the complete presentation is up and available. (Should be by this coming Wednesday.
great day, Werner On Thu, Jul 17, 2008 at 2:10 PM, Jason Purcell <[EMAIL PROTECTED]> wrote: > Hi... > > I have console and file logging configured in a properties file. > > I want to set the priority for the file as DEBUG and the one for the > console as INFO. How do I do this? > > The priority for my logger is set to DEBUG. > > Is it even possible in Log4J? > > Regards, > Jason. > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CTJUG Tech" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.co.za/group/CTJUG-Tech?hl=en -~----------~----~----~----~------~----~------~--~---
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"> <!-- A custom Renderer --> <renderer renderedClass="com.kookedsushi.log4j.rendering.KSGuy" renderingClass="com.kookedsushi.log4j.rendering.KSGuyLogRenderer"/> <!-- # Description of the pattern used below: # %d - The full Date # %r - the milliseconds since system startup # %t - The thread signature of the logging class # %x - The NDC Stack identifier # %-5p - The priority level used # %c - The catogory (in this case the class) # %m%n - The message followed by a new line. # # For more options refer to the PatternLayout class in the log4j API # # Configure the Console appender for general Standard Out. # --> <appender name="console" class="org.apache.log4j.ConsoleAppender"> <param name="Threshold" value="DEBUG"/> <param name="Target" value="System.out"/> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" value="%d (%r) [%t] %x %-5p %c - %m%n"/> </layout> </appender> <!-- # # Configure a general appender that will log to a RollingFileAppender. # There are loads of appender types available. Check the API # --> <appender name="file.general" class="org.apache.log4j.DailyRollingFileAppender"> <param name="Threshold" value="INFO"/> <param name="File" value="logs/general.log"/> <param name="DatePattern" value="'.'yyyy-MM-dd"/> <param name="Append" value="true"/> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" value="%d (%r) [%t] %-5p %c - %m%n"/> </layout> </appender> <!-- # # Configure a package specific appender # --> <appender name="file.ext" class="org.apache.log4j.DailyRollingFileAppender"> <param name="Threshold" value="DEBUG"/> <param name="File" value="logs/myEXTlog.log"/> <param name="DatePattern" value="'.'yyyy-MM-dd"/> <param name="Append" value="true"/> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" value="%d (%r) [%t] %-5p %c - %m%n"/> </layout> </appender> <!-- An email appender Running Virtual SMTP under IIS 6 for testing in Windows XP SMTP set locally to drop in C:\Inetpub\mailroot\Drop\ --> <appender name="mail" class="org.apache.log4j.net.SMTPAppender"> <param name="Threshold" value="INFO"/> <param name="To" value="[EMAIL PROTECTED]"/> <param name="From" value="[EMAIL PROTECTED]"/> <param name="Subject" value="log4j Examples"/> <param name="SMTPHost" value="localhost"/> <param name="BufferSize" value="10"/> <layout class="org.apache.log4j.HTMLLayout"> </layout> </appender> <!-- Logging by Category --> <category name="useFullStuff"> <appender-ref ref="file.ext"/> </category> <!-- Specific logger --> <logger name="com.kookedsushi.log4j.ext" additivity="false"> <appender-ref ref="file.ext" /> </logger> <!-- Specific logger for Emailing --> <logger name="com.kookedsushi.log4j.appenders.KSLogToSMTP" additivity="false"> <appender-ref ref="mail" /> </logger> <root> <!-- tolerance --> <priority value ="debug" /> <!-- Appenders registered with this category --> <appender-ref ref="console" /> <appender-ref ref="file.general" /> </root> </log4j:configuration>
