473,394 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

How can I get FlatFileSinkData file name from loggingDistributorCo

I would like to open a log file in a windows UI that corresponds to the file
maintained in the loggingDistributorConfig.config file. Has any one done this?

Below is the code I tried to use and the loggingDistributorConfig.config xml.

Thanks in Advance,

Mark
//start by capturing the configuration of the Logging with a logging
configuration view object
LoggingConfigurationView logConfigVw;
logConfigVw = new LoggingConfigurationView(new
ConfigurationContext(Path.GetFullPath("ShowLogFile Test.exe.config").ToString()));

//drill down in to the category
Microsoft.Practices.EnterpriseLibrary.Logging.Dist ributor.Configuration.CategoryData
distribConfig = logConfigVw.GetCategoryData("loggingDistributorCon fig.config
");

//drill down to the desination data
Microsoft.Practices.EnterpriseLibrary.Logging.Dist ributor.Configuration.DestinationData
destCollection = distribConfig.DestinationDataCollection["Flat File
Destination"];

//invalid cast error occurs on the following line when drilling into the
sink data
CustomSinkData mySinkData =
(CustomSinkData)logConfigVw.GetSinkData(destCollec tion.Sink);

//**** Config xml

<?xml version="1.0" encoding="utf-8"?>
<loggingDistributorConfiguration>
<xmlSerializerSection
type="Microsoft.Practices.EnterpriseLibrary.Loggin g.Distributor.Configuration.DistributorSettings,
Microsoft.Practices.EnterpriseLibrary.Logging, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=02d410f519fd6098">
<enterpriseLibrary.loggingDistributorSettings
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
defaultCategory="General" defaultFormatter="Text Formatter"
xmlns="http://www.microsoft.com/practices/enterpriselibrary/08-31-2004/loggingdistributor">
<sinks>
<sink xsi:type="EventLogSinkData" name="Event Log Sink"
eventLogName="Application" eventSourceName="Enterprise Library Logging" />
<sink xsi:type="FlatFileSinkData" name="Flat File Sink"
fileName="E:\Data\Logs\Tool\ApplicationLog.txt"
header="----------------------------------------"
footer="----------------------------------------" />
<sink xsi:type="MsmqSinkData" name="MSMQ Sink"
queuePath="mw10626\private$\Logging" priority="Normal" recoverable="false"
useAuthentication="false" useDeadLetterQueue="false" useEncryption="false" />
</sinks>
<categories>
<category name="General">
<destinations>
<destination name="Event Log Destination" sink="Event Log Sink"
format="Text Formatter" />
</destinations>
</category>
<category name="LoggingHandler">
<destinations>
<destination name="Flat File Destination" sink="Flat File Sink"
format="Text Formatter" />
</destinations>
</category>
<category name="Trace">
<destinations>
<destination name="Flat File Destination" sink="Flat File Sink"
format="Text Formatter" />
</destinations>
</category>
</categories>
<formatters>
<formatter xsi:type="TextFormatterData" name="Text Formatter">
<template><![CDATA[Timestamp: {timestamp}
Message: {message}
Category: {category}
Priority: {priority}
EventId: {eventid}
Severity: {severity}
Title:{title}
Machine: {machine}
Application Domain: {appDomain}
Process Id: {processId}
Process Name: {processName}
Win32 Thread Id: {win32ThreadId}
Thread Name: {threadName}
Extended Properties: {dictionary({key} - {value}
)}]]></template>
</formatter>
</formatters>
</enterpriseLibrary.loggingDistributorSettings>
</xmlSerializerSection>
</loggingDistributorConfiguration>
Dec 14 '05 #1
0 1604

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: matt | last post by:
I have compiled some code, some written by me, some compiled from various sources online, and basically i've got a very simple flat file photo gallery. An upload form, to upload the photos and give...
5
by: Dave Smithz | last post by:
Hi There, I have a PHP script that sends an email with attachment and works great when provided the path to the file to send. However this file needs to be on the same server as the script. ...
14
by: Xah Lee | last post by:
Just bumped into another irresponsibility in perl. the crime in question this time is the module File::Basename. Reproduction: 1. create a directory containing a file of this name:...
4
by: M P | last post by:
Can you help me find an asp code that will upload a file from my PC to web server? Mark
5
by: matt dittman | last post by:
I have created a windows service that reads emails from a drop directory and moves them to the appropriate mail folder every 15 seconds. I can move, rename and delete the files as needed, up...
5
by: Gregg | last post by:
Hello all, I have been banging my head over a problem that I am having reading a comma seperated file (CSV) that can contain from 1 to 10,000 records. My code snipit is as follows: **Start...
3
by: Abhas | last post by:
> > Hi, this is Abhas, > > I had made a video library program in C++, but was facing a problem. > > After entering 12 movies, i cannot enter any more movies. > > Something gibberish comes instead....
8
by: Sam Collett | last post by:
Is there a basic guide on Xml document creation and editing (simpler than the MSDN docs). Say I want to create a file containing the following: <?xml version="1.0" encoding="utf-8"...
185
by: jacob navia | last post by:
Hi We are rewriting the libc for the 64 bit version of lcc-win and we have added a new field in the FILE structure: char *FileName; fopen() will save the file name and an accessor function will...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.