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
- Model3D.cs
- SettingsPropertyIsReadOnlyException.cs
- WebPartExportVerb.cs
- FixUpCollection.cs
- SelectionEditor.cs
- DoubleStorage.cs
- GeneralTransform3DTo2DTo3D.cs
- QueryAccessibilityHelpEvent.cs
- DesignTimeParseData.cs
- NGCSerializationManager.cs
- DataGridViewSelectedCellsAccessibleObject.cs
- VisualTreeHelper.cs
- Compiler.cs
- WebControlParameterProxy.cs
- ObjectFullSpanRewriter.cs
- WebServiceMethodData.cs
- ImpersonationContext.cs
- OperationSelectorBehavior.cs
- EndOfStreamException.cs
- XmlWhitespace.cs
- TextDecorationCollection.cs
- Int32Storage.cs
- ObjectDataSourceView.cs
- PageThemeCodeDomTreeGenerator.cs
- SpellerHighlightLayer.cs
- WebMessageBodyStyleHelper.cs
- SecureUICommand.cs
- SmtpFailedRecipientException.cs
- TextRangeAdaptor.cs
- PrintPreviewGraphics.cs
- FontSizeConverter.cs
- GradientStop.cs
- ButtonBase.cs
- ValidationRuleCollection.cs
- BoolExpr.cs
- FakeModelPropertyImpl.cs
- FileSystemInfo.cs
- ObjectDataSource.cs
- RemotingServices.cs
- ConfigurationManagerInternal.cs
- DoubleAnimationClockResource.cs
- EndpointConfigContainer.cs
- ConfigurationSchemaErrors.cs
- DefaultBindingPropertyAttribute.cs
- ObjectStateEntryDbDataRecord.cs
- AsyncOperation.cs
- ConstraintCollection.cs
- EntitySetDataBindingList.cs
- DetailsViewDeletedEventArgs.cs
- GorillaCodec.cs
- XmlElementCollection.cs
- ExpressionWriter.cs
- Misc.cs
- SaveFileDialog.cs
- Matrix3D.cs
- AssemblyCacheEntry.cs
- SystemNetworkInterface.cs
- DragCompletedEventArgs.cs
- SplayTreeNode.cs
- ActiveXContainer.cs
- Misc.cs
- NonSerializedAttribute.cs
- VScrollProperties.cs
- SQLDateTimeStorage.cs
- ArrangedElement.cs
- EditorAttribute.cs
- PassportAuthentication.cs
- QuaternionValueSerializer.cs
- SystemIPv6InterfaceProperties.cs
- Screen.cs
- OutputCacheSettings.cs
- AutomationEventArgs.cs
- SystemGatewayIPAddressInformation.cs
- DbProviderFactoriesConfigurationHandler.cs
- UnsafeNativeMethods.cs
- XsltContext.cs
- ResourceExpressionBuilder.cs
- BaseInfoTable.cs
- GatewayDefinition.cs
- Privilege.cs
- SafeIUnknown.cs
- WmfPlaceableFileHeader.cs
- SoapEnumAttribute.cs
- BitmapEffect.cs
- SqlGatherConsumedAliases.cs
- ReferentialConstraint.cs
- SID.cs
- CodeMemberField.cs
- ToolStripLabel.cs
- serverconfig.cs
- CategoryAttribute.cs
- RelationshipFixer.cs
- XmlCustomFormatter.cs
- RecipientInfo.cs
- CodeSubDirectoriesCollection.cs
- HostedElements.cs
- CacheSection.cs
- ColumnResizeAdorner.cs
- CapabilitiesSection.cs
- SocketElement.cs