logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <raghuram.raicho...@accenture.com>
Subject RE: Can we write the data to Multiple log
Date Tue, 18 Aug 2009 15:47:13 GMT
Somehow I was able to manage to create two appenders based on the
configuration file data. Which is clipped along.

And wanted to know if this is good in move. 

 

static VWLogger()

        {

            if (tivoliLogger == null)

            {

                tivoliLogger = LoggerFactory.GetLogger("Tivoli");

            }

 

            if (appLogger == null)

            {

                appLogger = LoggerFactory.GetLogger("Application");

            }

        }

 

 

private void ConfigureLog(string mode)

        {

            Logger root = (Logger)log.Logger;

 

            foreach (Appender a in ConfigurationSettings.Appenders)

            {

                if (a.Mode == mode)

                {

                    root.AddAppender(GetFileAppender(a));

                }

            }

 

            root.Repository.Configured = true;

        }

 

        private static RollingFileAppender GetFileAppender(Appender a)

        {

            RollingFileAppender lAppender   = new RollingFileAppender();


            lAppender.Name                  = a.Name;

            lAppender.AppendToFile          = a.AppendToFile;

            lAppender.File                  = a.File;

            lAppender.RollingStyle          = a.RollingStyle;

            lAppender.MaxSizeRollBackups    = a.MaxSizeRollBackups;

            lAppender.MaxFileSize           = a.MaxFileSize;

            lAppender.Threshold             = a.LogLevel;

            lAppender.StaticLogFileName     = a.StaticLogName;

            lAppender.Layout                = new
log4net.Layout.PatternLayout(a.Layout);

 

            lAppender.ActivateOptions();

 

            return lAppender;

        }

 

And getting the setting from 

 

  static ConfigurationSettings()

        {

            XmlNode xNode;

            XmlNodeList list;

            Appender lAppender;

 

            XmlDocument xdoc = new XmlDocument();

 
xdoc.Load(@"C:\Sources\_diss\elsa\elsa\WebUIProjects\Disk\config\logging
.config");

            

            list = xdoc.SelectNodes("//SystemInformation");

            foreach (XmlNode node in list)

            {

                xNode = node.SelectSingleNode("SystemID");

                systemID = xNode.InnerText;

 

                xNode = node.SelectSingleNode("ErrorCodeList");

                errorCodeListPath = xNode.InnerText;

            }

 

            list = xdoc.SelectNodes("//Appender");

            foreach (XmlNode node in list)

            {

                lAppender = new Appender();

 

                xNode = node.SelectSingleNode("Mode");

                lAppender.Mode = xNode.InnerText;

 

                xNode = node.SelectSingleNode("Name");

                lAppender.Name = xNode.InnerText;

 

                xNode = node.SelectSingleNode("File");

                lAppender.File = xNode.InnerText;

 

                xNode = node.SelectSingleNode("AppendToFile");

                lAppender.AppendToFile =
Convert.ToBoolean(xNode.InnerText);

 

                xNode = node.SelectSingleNode("RollingStyle");

                lAppender.RollingStyle =
(RollingFileAppender.RollingMode)Enum.Parse(typeof(RollingFileAppender.R
ollingMode), xNode.InnerText, true);

 

                xNode = node.SelectSingleNode("MaxSizeRollBackups");

                lAppender.MaxSizeRollBackups =
Convert.ToInt32(xNode.InnerText);

 

                xNode = node.SelectSingleNode("MaxFileSize");

                lAppender.MaxFileSize =
Convert.ToInt32(xNode.InnerText);

 

                xNode = node.SelectSingleNode("MaxEntriesPerSecond");

                lAppender.MaxEntriesPerSecond =
Convert.ToInt32(xNode.InnerText);

 

                xNode = node.SelectSingleNode("Level");

                lAppender.LogLevel = GetLogLevel(xNode.InnerText);

 

                xNode = node.SelectSingleNode("StaticLogFileName");

                lAppender.StaticLogName =
Convert.ToBoolean(xNode.InnerText); 

 

                xNode = node.SelectSingleNode("Layout");

                lAppender.Layout = xNode.InnerText;

 

                Appenders.Add(lAppender);

            }

        }

 

Thanks & Regards,

Raghuram Raichooti 
________________________________________________________________________
________________________________________
Accenture Solutions 
Building 1B, Raheja Mindspace, Madhapur, Hi-tech City, Hyderabad-81,
INDIA 
Tel: +91 40 669 27208 | Mobile: +91 98661 83441 | Fax: +91 40 669 26001 
E-Mail: raghuram.raichooti@accenture.com
<mailto:name.surname@accenture.com>  | MSN: rvs_raghu@hotmail.com
<mailto:rvs_raghu@hotmail.com>  | AIM: raghuraichooti

 

From: Karim Bourouba [mailto:karym6@hotmail.com] 
Sent: Tuesday, August 18, 2009 8:51 PM
To: log4net-user@logging.apache.org
Subject: RE: Can we write the data to Multiple log

 

I am sorry, I am more than willing to provide help to you, but I dont
really have the time to go through all of your code. You sent me an
entire project. 

  

Can you not just explain what you have done so far and what problems you
have faced? I know this sounds bad, but there have been quite a few very
good examples of routes you can take with this already posted.



  
> Subject: RE: Can we write the data to Multiple log
> Date: Tue, 18 Aug 2009 19:36:55 +0530
> From: raghuram.raichooti@accenture.com
> To: log4net-user@logging.apache.org; log4net-user@logging.apache.org
> 
> Hi,
> 
> Please find the sample example which i am doing. and please suggest me
if i did something wrong.
> 
> Thanks & Regards,
>
________________________________________________________________________
____________________
> Raghuram Raichooti
> 
> 
> ________________________________
> 
> From: Karim Bourouba [mailto:karym6@hotmail.com]
> Sent: Tue 18.08.2009 13:18
> To: log4net-user@logging.apache.org
> Subject: RE: Can we write the data to Multiple log
> 
> 
> I think the point I failed to make is this; in my opinion, handling
the logging from the UI is a bad thing, just configure your application
to log as soon as it is started. 
> 
> Ron Grabowski sent a good example of how to do what you want to do, to
which you replied. Failing that, just include two rolling fille
appeneders in your config file set to look at different levels, i.e.
everything for the developers and then a different level for everyone
else. 
> 
> I think the biggest question here is what have you tried so far and
what problems did you encounter?
> 
> 
> 
> 
> 
> ________________________________
> 
> Subject: RE: Can we write the data to Multiple log
> Date: Tue, 18 Aug 2009 12:42:53 +0530
> From: raghuram.raichooti@accenture.com
> To: log4net-user@logging.apache.org
> 
> 
> 
> OK are not suppose to use the DB.
> 
> 
> 
> Coming to logging. I need to use RollingFileAppenders for both of the
Logs.
> 
> When you say two logs, its one for the Application Developers who
needs to get complete information for them to track. 
> 
> And the other log is for the Tivoli server which keeps tracking the
information of the logs.
> 
> 
> 
> And from UI I normally use only one statement saying 
> 
> 
> 
> Private readonly log4net.ILog Log = log4net.logManager.GetLogger("")
> 
> Log.Debug(GetformatedMessage("Application"));
> 
> Log.Debug(GetformatedMessage("Tivoli"));
> 
> 
> 
> I was asking you how can we write the information to the different
logs.
> 
> 
> 
> Regards,
> 
> Raghuram Raichooti 
>
________________________________________________________________________
________________________________________
> 
> 
> 
> From: Karim Bourouba [mailto:karym6@hotmail.com] 
> Sent: Tuesday, August 18, 2009 12:29 PM
> To: log4net-user@logging.apache.org
> Subject: RE: Can we write the data to Multiple log
> 
> 
> 
> Without sounding contrite, I think the group provided guidance to you
yesterday on how to do this? The suggestions were to either configure
two rolling file appenders or log to a DB. 
> 
> 
> 
> Why do you need to include anything in your UI? This is only my
position on this, but - why do you want to specify which log you want to
use in the UI? Doesnt this reduce the value of your logging by quite
some degree?
> 
> 
> 
> 
> 
> ________________________________
> 
> Subject: RE: Can we write the data to Multiple log
> Date: Tue, 18 Aug 2009 12:13:53 +0530
> From: raghuram.raichooti@accenture.com
> To: log4net-user@logging.apache.org
> 
> Hi,
> 
> From the UI how can I specify the details to which appender to use.
> 
> 
> 
> My requirement is like there will be two log:
> 
> - Complete Information, which contains data along with the stack trace
and many more parameters coming from the exception
> 
> - Simple information saying "There was a error with code and simple
details"
> 
> 
> 
> And in this case I need to log them in two different logs at a time.
> 
> 
> 
> Can you please send me the samples. 
> 
> 
> 
> Thanks in advance.
> 
> 
> 
> Regards,
> 
> Raghuram Raichooti 
>
________________________________________________________________________
________________________________________
> 
> 
> 
> From: Ron Grabowski [mailto:rongrabowski@yahoo.com] 
> Sent: Tuesday, August 18, 2009 7:06 AM
> To: Log4NET User
> Subject: Re: Can we write the data to Multiple log
> 
> 
> 
> Does this example help?
> 
> <?xml version="1.0" encoding="utf-8" ?>
> <log4net>
> <appender name="SimpleLayoutFileAppender"
type="log4net.Appender.FileAppender">
> <file value="Logs\Simple.txt" />
> <layout type="log4net.Layout.SimpleLayout" />
> </appender>
> <appender name="PatternLayoutFileAppender"
type="log4net.Appender.FileAppender">
> <file value="Logs\PatternLayout.txt" />
> <layout type="log4net.Layout.PatternLayout">
> <conversionPattern value="%5level %date (%logger:%line) -
%message%newline" />
> </layout>
> </appender>
> <root>
> <appender-ref ref="SimpleLayoutFileAppender" />
> <appender-ref ref="PatternLayoutFileAppender" />
> </root>
> </log4net>
> 
> 
> 
> ________________________________
> 
> From: "raghuram.raichooti@accenture.com"
<raghuram.raichooti@accenture.com>
> To: log4net-user@logging.apache.org
> Sent: Monday, August 17, 2009 4:16:42 AM
> Subject: Can we write the data to Multiple log
> 
> 
> 
> Hi,
> 
> 
> 
> I am using the Rolling File Appender, and in this I would like to
write the exception raised to two different logs one with simple
information and other with the complete information.
> 
> 
> 
> In the config file I have two sections defining the paths.
> 
> 
> 
> <?xml version="1.0" standalone="yes" ?>
> 
> <SYSTEMINFORMATION>
> 
> <SYSTEMID>DIS</SYSTEMID>
> 
> <ERRORCODELISTPATH>/config/errorCode.xml</ERRORCODELISTPATH>
> 
> </SYSTEMINFORMATION>
> 
> 
> 
> <APPENDER MODE="tivoli" NAME="RollingLogFileAppender"
TYPE="log4net.Appender.RollingFileAppender">
> 
> <FILENAME VALUE="d://svr_app_prod//logs//app_logs//diss//tivoli.log"
/>
> 
> <APPENDTOFILE VALUE="true" />
> 
> <ROLLINGSTYLE VALUE="Size" />
> 
> <MAXROLLBACKUPSIZE VALUE="10" />
> 
> <MAXFILESIZE VALUE="10MB" />
> 
> <MAXENTRIESPERSECOND VALUE="10" />
> 
> <STATICLOGFILENAME VALUE="true" />
> 
> <LAYOUT TYPE="log4net.Layout.PatternLayout">
> 
> <CONVERSIONPATTERN VALUE="%date [%thread] %-5level %logger
[%property{ndc}] - %message%newline" />
> 
> </LAYOUT>
> 
> </APPENDER>
> 
> 
> 
> <APPENDER MODE="application" NAME="RollingLogFileAppender"
TYPE="log4net.Appender.RollingFileAppender">
> 
> <FILENAME
VALUE="d://svr_app_prod//logs//app_logs//diss//application.log" />
> 
> <APPENDTOFILE VALUE="true" />
> 
> <ROLLINGSTYLE VALUE="Size" />
> 
> <MAXROLLBACKUPSIZE VALUE="50" />
> 
> <MAXFILESIZE VALUE="50MB" />
> 
> <MAXENTRIESPERSECOND VALUE="10" />
> 
> <STATICLOGFILENAME VALUE="true" />
> 
> <LAYOUT TYPE="log4net.Layout.PatternLayout">
> 
> <CONVERSIONPATTERN VALUE="%date [%thread] %-5level %logger
[%property{ndc}] - %message%newline" />
> 
> </LAYOUT>
> 
> </APPENDER>
> 
> </DataSetConfiguration>
> 
> 
> 
> In our application we only mention Log.Debug("Logging Information"). 
> 
> 
> 
> Could you please tell me how to specify the details of the log file.
> 
> 
> 
> Regards,
> 
> Raghuram Raichooti 
>
________________________________________________________________________
________________________________________
> 
> 
> 
> This message is for the designated recipient only and may contain
privileged, proprietary, or otherwise private information. If you have
received it in error, please notify the sender immediately and delete
the original. Any other use of the email by you is prohibited.
> 
> 
> 
> This message is for the designated recipient only and may contain
privileged, proprietary, or otherwise private information. If you have
received it in error, please notify the sender immediately and delete
the original. Any other use of the email by you is prohibited.
> 
> 
> 
> ________________________________
> 
> Windows Live Messenger: Celebrate 10 amazing years with free winks and
emoticons. Get Them Now
<http://clk.atdmt.com/UKM/go/157562755/direct/01/> 
> 
> 
> This message is for the designated recipient only and may contain
privileged, proprietary, or otherwise private information. If you have
received it in error, please notify the sender immediately and delete
the original. Any other use of the email by you is prohibited.
> 
> 
> ________________________________
> 
> Windows Live Messenger: Celebrate 10 amazing years with free winks and
emoticons. Get Them Now
<http://clk.atdmt.com/UKM/go/157562755/direct/01/> 
> 
> 
> This message is for the designated recipient only and may contain
privileged, proprietary, or otherwise private information. If you have
received it in error, please notify the sender immediately and delete
the original. Any other use of the email by you is prohibited.

________________________________

Internet Explorer 8 - accelerate your Hotmail. Download Internet
Explorer 8 <http://clk.atdmt.com/UKM/go/134665338/direct/01/> 


Mime
View raw message