Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / Tools / xws_reg / System / ServiceModel / Install / EventLogger.cs / 1 / EventLogger.cs
//------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------- namespace System.ServiceModel.Install { using System; using System.Diagnostics; using System.Globalization; using System.ComponentModel; internal static class EventLogger { const int MaxEventLogLength = 32768; static MsiStyleLogWriter msiStyleLogWriter = null; static EventLogger() { if (!EventLog.SourceExists(ServiceModelInstallStrings.EventLogSource)) { EventLog.CreateEventSource(ServiceModelInstallStrings.EventLogSource, ServiceModelInstallStrings.EventLogName); } } internal static void InitializeMsiStyleLogging() { EventLogger.msiStyleLogWriter = MsiStyleLogWriter.CreateWriter(); } internal static void TerminateMsiStyleLogging() { if (EventLogger.msiStyleLogWriter != null) { DateTime now = DateTime.Now; EventLogger.msiStyleLogWriter.WriteRaw(SR.GetString(SR.MsiStyleLogTerminator, now.ToShortDateString(), now.ToString("HH:mm:ss", CultureInfo.CurrentCulture))); } EventLogger.msiStyleLogWriter = null; } internal static void LogException(Exception e) { EventLogger.LogToConsole(SR.GetString(SR.Error, e.Message)); EventLogger.WriteMsiStyleLogEntry(e.ToString()); EventLogger.WriteLogEntry(e.ToString(), EventLogEntryType.Error); } internal static void LogError(string message) { EventLogger.LogToConsole(message); EventLogger.WriteMsiStyleLogEntry(SR.GetString(SR.Error, message)); EventLogger.WriteLogEntry(message, EventLogEntryType.Error); } internal static void LogInformation(string message, bool displayToConsole) { if (displayToConsole) { EventLogger.LogToConsole(message); } EventLogger.WriteMsiStyleLogEntry(SR.GetString(SR.Information, message)); EventLogger.WriteLogEntry(message, EventLogEntryType.Information); } internal static void LogToConsole(string message) { Console.WriteLine(); Console.WriteLine(message); } internal static void LogWarning(string message, bool displayToConsole) { if (displayToConsole) { EventLogger.LogToConsole(message); } EventLogger.WriteMsiStyleLogEntry(SR.GetString(SR.Warning, message)); EventLogger.WriteLogEntry(message, EventLogEntryType.Warning); } internal static void WriteLogEntry(string message, EventLogEntryType entryType) { try { EventLog.WriteEntry(ServiceModelInstallStrings.EventLogSource, message.Trim(), entryType); } catch (ArgumentException e) { // Issues related to message length EventLogger.WriteMsiStyleLogEntry(SR.GetString(SR.ErrorWritingEventLogEntry, e.ToString())); } catch (InvalidOperationException e) { // Registry access issues EventLogger.WriteMsiStyleLogEntry(SR.GetString(SR.ErrorWritingEventLogEntry, e.ToString())); } catch (Win32Exception e) { // Other OS reported issues EventLogger.WriteMsiStyleLogEntry(SR.GetString(SR.ErrorWritingEventLogEntry, e.ToString())); } } internal static void WriteMsiStyleLogEntry(string message) { if (EventLogger.msiStyleLogWriter != null) { EventLogger.msiStyleLogWriter.WriteEntry(message); } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- RecipientServiceModelSecurityTokenRequirement.cs
- ProcessInputEventArgs.cs
- DataGridRowEventArgs.cs
- Clause.cs
- TableRow.cs
- Serializer.cs
- DrawListViewItemEventArgs.cs
- CollectionEditor.cs
- Menu.cs
- NamespaceEmitter.cs
- ArrayElementGridEntry.cs
- DictionaryBase.cs
- TableLayoutStyle.cs
- StreamUpdate.cs
- LogEntryDeserializer.cs
- COM2ComponentEditor.cs
- SelectionItemProviderWrapper.cs
- PermissionRequestEvidence.cs
- EditorPartCollection.cs
- ConvertEvent.cs
- UInt32Storage.cs
- GetIndexBinder.cs
- TdsParserSessionPool.cs
- XPathException.cs
- UnauthorizedWebPart.cs
- TextRangeAdaptor.cs
- ObjectStateEntry.cs
- DataGridItemCollection.cs
- VirtualPath.cs
- DataGridViewCellFormattingEventArgs.cs
- MembershipPasswordException.cs
- UnmanagedHandle.cs
- RunClient.cs
- EntityDataSourceReferenceGroup.cs
- PrimitiveSchema.cs
- ConfigurationSettings.cs
- ProviderIncompatibleException.cs
- ServiceTimeoutsElement.cs
- HMACSHA256.cs
- SQLInt16Storage.cs
- XPathBinder.cs
- RotationValidation.cs
- BoolExpressionVisitors.cs
- SqlUdtInfo.cs
- BamlCollectionHolder.cs
- MessageVersionConverter.cs
- ProviderConnectionPointCollection.cs
- ComplusEndpointConfigContainer.cs
- WsatConfiguration.cs
- SqlBinder.cs
- XmlnsPrefixAttribute.cs
- FolderNameEditor.cs
- PagesSection.cs
- AnnotationResource.cs
- BookmarkWorkItem.cs
- CodeGenerator.cs
- MutexSecurity.cs
- SqlProviderManifest.cs
- SqlProfileProvider.cs
- CompositeTypefaceMetrics.cs
- XmlBuffer.cs
- SqlFactory.cs
- DesignerDataView.cs
- FixedHighlight.cs
- ClosableStream.cs
- XmlDataSource.cs
- AnnotationElement.cs
- FtpRequestCacheValidator.cs
- ClientSideQueueItem.cs
- XPathExpr.cs
- SQLInt32.cs
- CacheSection.cs
- ThicknessAnimationUsingKeyFrames.cs
- ImmutableObjectAttribute.cs
- BamlWriter.cs
- EncryptedHeaderXml.cs
- XmlParser.cs
- ToolStripHighContrastRenderer.cs
- Point4D.cs
- XmlAttribute.cs
- MenuItemStyleCollection.cs
- RequestQueryParser.cs
- XmlWriter.cs
- MediaContext.cs
- EllipseGeometry.cs
- WindowsStatic.cs
- SubMenuStyle.cs
- UrlMappingsModule.cs
- ExtensionSimplifierMarkupObject.cs
- DesignerTextViewAdapter.cs
- XPathNavigatorReader.cs
- DockingAttribute.cs
- PropertyItem.cs
- EntityDescriptor.cs
- CollectionBase.cs
- SqlProfileProvider.cs
- ToolStripDropTargetManager.cs
- SHA384CryptoServiceProvider.cs
- DocumentViewerAutomationPeer.cs
- ContentValidator.cs