Custom Logging Messages from an biztalk Orchestration into a log
- From: Pradeep Earla <PradeepEarla@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 17 Sep 2008 07:23:01 -0700
Hi,
I am facing issue in logging to a file using Enterprise Library 3.1. Can
some let me know what is going wrong by looking into following scenarios?
Scenario-1:
Usually if we take BTSNSVc.exe.config file to define <configSections> and
<loggingConfiguration> sections,
in the user defined logger class we use the Logger class of
Microsoft.Practices.EnterpriseLibrary.Logging to write entries to log file.
public void LogMessageToFile(string message)
{
LogEntry logEntry = new LogEntry();
logEntry.Message = message;
logEntry.Categories.Add("FlatFile Category");
Logger.Write(logEntry);
}
In this scenario all messages are written to one log file and a new log file
will be created if it gets saturated.
Scenario-2:
But here we have to use application specific config file (xyz.config) for
defining <configSections> and <loggingConfiguration> sections instead of
BTSNSVc.exe.config as we are not supposed to touch BizTalk config file. So in
our logger class we have used LogWriter to write entries to log file.
public void LogMessageToFile(string message)
{
LogWriter writer = null;
//getting the path of the xyz.config file which is configured in
BTSNSVc.exe.config file
string configFileLocation =
System.Configuration.ConfigurationSettings.AppSettings["FDFBBDataServiceConfigFile"];
// reading the <configSections> and <loggingConfiguration> sections from
xyz.config
FileConfigurationSource source = new
FileConfigurationSource(configFileLocation);
LogWriterFactory factory = new LogWriterFactory(source);
writer = factory.Create();
LogEntry logEntry = new LogEntry();
logEntry.Message = string.Format(message);
logEntry.Categories.Add("FlatFile Category");
writer.Write(logEntry);
}
}
In this scenario first entry is going to log file while other entries, each
one is going to a new log file(this filename is prefixed with a GUID as shown
below).
LogFile.log
2baf2ae4-55d0-4921-b549-8dba63a146c4LogFile.log
d9f454cb-93e9-4465-83a4-215d542d6109LogFile.log
We also wanted this log to be generated on daily basis so tried
RollingFlatFileTraceListener and FlatFileListener.
Expected result is only one log file to be created in a day with all the log
entries for that day.
NOTE: <configSections> and <loggingConfiguration> sections are same in both
scenarios
Thanks,
Pradeep
.
- Prev by Date: RE: This Assembler cannot retrieve a document specification using this
- Next by Date: Custom Logging Messages from an biztalk Orchestration into a log
- Previous by thread: RE: Administration Console CLSID_BizTalkPropertyBagFactory error.
- Next by thread: Custom Logging Messages from an biztalk Orchestration into a log
- Index(es):
Relevant Pages
|