本文整理汇总了C#中Microsoft.Practices.EnterpriseLibrary.Logging.LogWriter类的典型用法代码示例。如果您正苦于以下问题:C# LogWriter类的具体用法?C# LogWriter怎么用?C# LogWriter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LogWriter类属于Microsoft.Practices.EnterpriseLibrary.Logging命名空间,在下文中一共展示了LogWriter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AccessImporter
public AccessImporter(LogWriter logger, LO30Context context, bool seed = true)
{
_logger = logger;
_context = context;
_lo30ContextService = new LO30ContextService(context);
_seed = seed;
}
示例2: LogService
static LogService()
{
var formatter = new TextFormatter
("Timestamp: {timestamp}{newline}" +
"Message: {message}{newline}" +
"Category: {category}{newline}");
//Create the Trace listeners
var logFileListener = new FlatFileTraceListener(@"C:\temp\temp.log", "",
"", formatter);
//Add the trace listeners to the source
var mainLogSource =
new LogSource("MainLogSource", SourceLevels.All);
mainLogSource.Listeners.Add(logFileListener);
var nonExistantLogSource = new LogSource("Empty");
IDictionary<string, LogSource> traceSources =
new Dictionary<string, LogSource>
{{"Info", mainLogSource}, {"Warning", mainLogSource}, {"Error", mainLogSource}};
Writer = new LogWriterImpl(new ILogFilter[0],
traceSources,
nonExistantLogSource,
nonExistantLogSource,
mainLogSource,
"Info",
false,
true);
}
示例3: MyLoggingExceptionHandler
internal MyLoggingExceptionHandler(string logCategory, int eventId, TraceEventType severity, string title, int priority,
Type formatterType, LogWriter writer, DocumentModel doc)
: base(logCategory, eventId, severity, title, priority, formatterType, writer)
{
this.m_Writer = writer;
this.doc = doc;
}
示例4: EnterpriseLibraryLogger
public EnterpriseLibraryLogger(LoggingConfiguration config)
{
if (config == null)
throw new ArgumentNullException("config");
m_LogWriter = new LogWriter(config);
}
示例5: ShellViewModel
public ShellViewModel(
IRegionManager regionManager,
IEventAggregator eventAggregator,
INavigationService navigationService,
IApplicationCommands applicationCommands,
LogWriter logWriter)
{
this.regionManager = regionManager;
this.eventAggregator = eventAggregator;
this.navigationService = navigationService;
this.applicationCommands = applicationCommands;
this.logWriter = logWriter;
this.EntitySelectorViews = new List<KeyValuePair<string, Type>>();
this.ExitCommand = new DelegateCommand<object>(this.AppExit, this.CanAppExit);
this.eventAggregator.Subscribe<BusyEvent>(this.SetBusy);
this.eventAggregator.Subscribe<DialogOpenEvent>(this.DialogOpened);
this.eventAggregator.Subscribe<StatusEvent>(this.UpdateStatus);
this.eventAggregator.Subscribe<ErrorEvent>(this.ShowError);
this.eventAggregator.Subscribe<CanSaveEvent>(this.UpdateCanSave);
this.eventAggregator.Subscribe<EntitySelectEvent>(this.ShowSelectEntity);
this.eventAggregator.Subscribe<EntitySelectedEvent>(this.HideSelectEntity);
this.eventAggregator.Subscribe<MappingUpdateEvent>(this.ShowUpdateMapping);
this.eventAggregator.Subscribe<MappingUpdatedEvent>(this.HideUpdateMapping);
this.eventAggregator.Subscribe<CanCreateNewChangeEvent>(this.CanCreateNewChange);
this.eventAggregator.Subscribe<CanCloneChangeEvent>(this.CanCloneChange);
this.eventAggregator.Subscribe<ConfirmMappingDeleteEvent>(this.ConfirmMappingDelete);
this.eventAggregator.Subscribe<MappingDeleteConfirmedEvent>(this.MappingDeleteConfirmed);
this.NewEntityMenuItems = new ObservableCollection<MenuItemViewModel>();
this.serverList = new ObservableCollection<string>();
this.SetServerList();
this.HelpToolTip = "Help Documentation (" + Assembly.GetExecutingAssembly().GetName().Version + ")";
}
示例6: Main
/// <summary>
///
/// </summary>
/// <param name="args"></param>
public static void Main(string[] args)
{
try
{
logWriter = ConfigureEntLibLogging.ConfigureLogWriter();
if (logWriter.IsLoggingEnabled())
{
using (logWriter)
{
logWriter.Write("Enterprise Library Logging test app has been started!");
}
}
//EntLibLogTest logTest = new EntLibLogTest();
//logTest.PrintLogEvent();
Console.ReadKey();
}
catch (Exception ex)
{
return;
}
finally
{
logWriter.Dispose();
}
}
示例7: SimpleLogWriterWrite
static void SimpleLogWriterWrite()
{
// Build the configuration programtically.
LoggingConfiguration loggingConfiguration = BuildProgrammaticConfig();
defaultWriter = new LogWriter(loggingConfiguration);
// Check if logging is enabled before creating log entries.
if (defaultWriter.IsLoggingEnabled())
{
// The default values if not specified in call to Write method are:
// - Category: "General"
// - Priority: -1
// - Event ID: 1
// - Severity: Information
// - Title: [none]
defaultWriter.Write("Log entry created using the simplest overload.");
Console.WriteLine("Created a Log Entry using the simplest overload.");
defaultWriter.Write("Log entry with a single category.", "General");
Console.WriteLine("Created a Log Entry with a single category.");
defaultWriter.Write("Log entry with a category, priority, and event ID.", "General", 6, 9001);
Console.WriteLine("Created a Log Entry with a category, priority, and event ID.");
defaultWriter.Write("Log entry with a category, priority, event ID, and severity.", "General", 5, 9002, TraceEventType.Warning);
Console.WriteLine("Created a Log Entry with a category, priority, event ID, and severity.");
defaultWriter.Write("Log entry with a category, priority, event ID, severity, and title.", "General", 8, 9003, TraceEventType.Warning, "Logging Block Examples");
Console.WriteLine("Created a Log Entry with a category, priority, event ID, severity, and title.");
Console.WriteLine();
Console.WriteLine(@"Open 'C:\Temp\ConfigSampleFlatFile.log' to see the results.");
}
else
{
Console.WriteLine("Logging is disabled in the configuration.");
}
}
示例8: Logger
private Logger()
{
TraceManager traceMgr;
DatabaseProviderFactory factory = new DatabaseProviderFactory(new SystemConfigurationSource(false).GetSection);
DatabaseFactory.SetDatabaseProviderFactory(factory, false);
LoggingConfiguration loggingConfiguration = BuildProgrammaticConfig();
defaultWriter = new LogWriter(loggingConfiguration);
// Create a TraceManager object for use in activity tracing example.
traceMgr = new TraceManager(defaultWriter);
try
{
if (!Directory.Exists(@"C:\Temp"))
{
Directory.CreateDirectory(@"C:\Temp");
}
}
catch
{
//Console.WriteLine(@"WARNING: Folder C:\Temp cannot be created for disk log files");
//Console.WriteLine();
}
}
示例9: LcboInventoryServiceAgent
/// <summary>
/// Initializes a new instance of the <see cref="LcboInventoryServiceAgent"/> class.
/// </summary>
/// <param name="pageRetrieverFactory">The page retriever factory.</param>
public LcboInventoryServiceAgent(
[ServiceDependency]IPageRetrieverFactory pageRetrieverFactory
)
{
this.pageRetriever = pageRetrieverFactory.InventoryPageRetriever;
this.logWriter = EnterpriseLibraryContainer.Current.GetInstance<LogWriter>();
this.traceManager = new TraceManager(this.logWriter);
}
示例10: MagicLogger
public MagicLogger()
{
var config = new LoggingConfiguration();
var txtFormatter = new TxtFormatter(new NameValueCollection());
config.AddLogSource("Error", SourceLevels.Error, true).AddTraceListener(new FlatFileListener("error.txt", formatter: txtFormatter));
config.AddLogSource("Information", SourceLevels.Information, true).AddTraceListener(new FlatFileListener("information.txt", formatter: txtFormatter));
var loggerWriter = new LogWriter(config);
Logger.SetLogWriter(loggerWriter, false);
}
示例11: CleanerService
public CleanerService()
{
InitializeComponent();
_logger = new LogWriter(BuildProgrammaticConfig());
_cacheDir = ConfigurationManager.AppSettings[OfficeCacheFolderKey];
_maxAgeMinutes = int.Parse(ConfigurationManager.AppSettings[LastAccessTimeMinutesBeforeDeleteKey]);
_cleanIntervalMinutes = int.Parse(ConfigurationManager.AppSettings[CleanIntervalMinutes]);
}
示例12: LcboProductServiceAgent
public LcboProductServiceAgent(
[ServiceDependency]IPageRetrieverFactory pageRetrieverFactory
)
{
this.productDetailsPageRetriever = pageRetrieverFactory.ProductDetailsPageRetriever;
this.productListPageRetriever = pageRetrieverFactory.ProductListPageRetriever;
this.logWriter = EnterpriseLibraryContainer.Current.GetInstance<LogWriter>();
this.traceManager = new TraceManager(this.logWriter);
}
示例13: EntLibLogger
public EntLibLogger(LogWriter logWriter)
{
if (logWriter == null)
{
throw new ArgumentNullException("logWriter");
}
this.logWriter = logWriter;
}
示例14: AdvSurveysController
public AdvSurveysController(ISurveyService surveyService,
IDipendentiService dipendentiService,
LogWriter logger
)
{
this.surveyService = surveyService;
this.logger = logger;
}
示例15: PersonalLocationsController
/// <summary>
/// Initializes a new instance of the <see cref="PersonalLocationsController"/> class.
/// </summary>
public PersonalLocationsController(
[CreateNew] IDomainContext domainContext,
[ServiceDependency] IGeoLocationServiceAgent geoLocationService
)
{
this.logWriter = EnterpriseLibraryContainer.Current.GetInstance<LogWriter>();
this.traceManager = new TraceManager(this.logWriter);
this.geoLocationService = geoLocationService;
this.domainContext = domainContext;
}