标签: event-log

从Sharepoint webpart中写入事件日志

我正在尝试创建自定义webpart.要实现错误处理,我想写入事件日志.为此,我正在尝试使用以下代码;

protected void btnExceptionTester_Click(object sender, EventArgs e)
    {
        try
        {
            throw new Exception("this is a test");
        }
        catch (Exception ex)
        {
            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                EventLog.WriteEntry("TestWebpart", ex.ToString(), EventLogEntryType.Error);
            });
        }
    }
Run Code Online (Sandbox Code Playgroud)

当我尝试执行此代码时,我收到一个sharepoint错误页面(未处理的异常).当我查看事件日志时,我看到以下消息; "不允许请求注册表访问".

我在完全信任级别下运行(仅用于测试).有人能指出我需要写什么样的特权才能写入事件日志?或者还有另一种方法吗?

帮助大大的appriciated!

sharepoint event-log

5
推荐指数
1
解决办法
9480
查看次数

EventLogReader远程性能

我正在使用EventLogReader来查询远程2008服务器的事件.在远程机器上查询事件的性能非常糟糕(每秒6次).如果我使用仅向前的ManagementObjectSearch通过WMI查询同一台机器,性能很好(1000 /秒).我没有在EventLogReader上看到任何类似的选项(例如ReturnImmediatly,Rewindable)来加速它.我尝试关闭远程服务器上的防火墙,看看是否存在通信问题,但这没有什么区别.

当使用EventLogReader从本地主机读取日志时,性能与预期一致 - 只有通过网络它才会减慢速度(但WMI不会遇到问题).

有什么方法可以通过网络加速EventLogReader的性能?

谢谢,米奇

.net c# performance event-log

5
推荐指数
1
解决办法
1943
查看次数

将事件日志组织到文件夹中

我想创建多个服务,我希望它们在我指定的同一目录/文件夹下的日志条目中记录每个服务,因此当我打开Windows事件查看器时,我可以看到它们都放在一个文件夹中.例如,service1将登录到service1_log,service2将登录到service2_log,service1_log和service2_log都将驻留在名为Myservices的一个文件夹中.我没有在Windows事件日志API或任何其他适合此问题的API中找到任何内容.我可以在Windows事件查看器中看到有文件夹,但我只能在日志层次结构的根目录中创建日志.

在此先感谢托马斯

c# windows event-log

5
推荐指数
1
解决办法
6201
查看次数

如何禁用.NET事件日志警告?

根据我们的政策,我们不再允许写入事件日志,因此我从写入事件日志中删除了所有事件日志代码,这是可行的,但是即使有以下情况,我仍会从错误中随机获取ASP.NET 4.0警告我的Application_Error中的代码来处理所有错误。

有什么方法可以完全禁用事件日志记录,可能是通过更改web.config或IIS设置来禁用它?

也注意到很多错误..不仅仅是我的HTTPHandler

EventLog记录的示例:

场次编码:3005 
事件消息:发生未处理的异常。 
活动时间:2011/9/8上午10:26:04 
活动时间(UTC):2011/9/8下午2:26:04 
事件ID:6b56761296d24e1aa01038ce125be044 
事件顺序:97 
事件发生:1 
事件详细代码:0 

应用信息: 
    应用域:/ LM / W3SVC / 1 / ROOT / -2-129599642336131368 
    信任等级:完整 
    应用程序虚拟路径:/
    申请路径: 
    机器名称: 

处理信息: 
    进程ID:6396 
    进程名称:w3wp.exe 
    帐户名称:IIS APPPOOL \ MyAppPool

异常信息: 
    异常类型:System.Exception
    异常消息:STACKTRACE


asp.net error-handling event-log

5
推荐指数
1
解决办法
4073
查看次数

powershell:get-winevent没有消息数据?

当我运行下面的脚本来检索日志文件时,get-winevent"message"字段为空,但是如果我运行get-eventlog则有数据.有什么想法吗?

#has message data 
Get-Eventlog -LogName application -Newest 10

 #date 10 days ago 
$EventStartDate = get-date("10 May 2012") 
$EventEndDate = get-date("11 May 2012") 
$EventLogNames = @("Application", "system")

#critea for winevent 
$EventCritea = @{logname = $EventLogNames; StartTime=$EventStartDate; EndTime=$EventEndDate}

#Retrieves the event log 
$RetreivedEvents = Get-WinEvent -computername localhost -FilterHashtable $EventCritea
$RetreivedEvents | fl id, logname, MachineName, Message, TimeCreated
Run Code Online (Sandbox Code Playgroud)

powershell event-log event-viewer

5
推荐指数
2
解决办法
7904
查看次数

如何从窗口azure访问事件日志

我想从Azure webrole的实例中获取窗口事件日志.当我连接到实例的RDP然后通过事件查看器我能够看到"应用程序"和"错误"类型的窗口事件日志.有没有办法使用API​​或其他东西直接访问日志,或者我需要使用Diagnostic来将日志数据传输到存储中,从那里我可以访问?

azure event-log

5
推荐指数
1
解决办法
1万
查看次数

导出EventLog时出现异常

我使用fallowing代码导出Windows-Event-Log:

var els = new EventLogSession();
els.ExportLogAndMessages("Application", 
                            PathType.LogName, 
                            "*[System[Provider[@Name='Prayon.Client']]]", 
                            tempEventLogPath, 
                            false, 
                            CultureInfo.CurrentCulture);
Run Code Online (Sandbox Code Playgroud)

这通常有效.但在一台机器上,我得到了一个例外:

System.Diagnostics.Eventing.Reader.EventLogException: Der Verzeichnisname ist ungültig
bei System.Diagnostics.Eventing.Reader.EventLogException.Throw(Int32 errorCode)
bei System.Diagnostics.Eventing.Reader.NativeWrapper.EvtArchiveExportedLog(EventLogHandle session, String logFilePath, Int32 locale, Int32 flags)
bei System.Diagnostics.Eventing.Reader.EventLogSession.ExportLogAndMessages(String path, PathType pathType, String query, String targetFilePath, Boolean tolerateQueryErrors, CultureInfo targetCultureInfo)
Run Code Online (Sandbox Code Playgroud)

"Der Verzeichnisname ist ungültig" 意思是英语: "The pathname is invalid"

Application-EventLog是现有的,tempEventLogPath也是有效的.

有人知道,有什么可能是错的吗?

.net c# event-log

5
推荐指数
1
解决办法
1093
查看次数

如何防止在事件日志中截断服务异常

我们有ac #windows服务失败,导致将错误日志消息写入Windows事件日志.错误消息包含异常信息,但它被截断,阻止我们查看关键信息.

我们如何增加写入日志消息的数据,以便我们可以看到异常的完整堆栈跟踪?

这是我们目前在事件查看器中看到的内容.

<EventData>
    <Data>Service cannot be started. System.ArgumentException: Keyword not supported: 'port'. 
 at System.Data.Common.DbConnectionOptions.ParseInternal(Hashtable parsetable, String connectionString, Boolean buildChain, Hashtable synonyms, Boolean firstKey) 
 at System.Data.Common.DbConnectionOptions..ctor(String connectionString, Hashtable synonyms, Boolean useOdbcRules) 
 at System.Data.SqlClient.SqlConnectionString..ctor(String connectionString) 
 at System.Data.SqlClient.SqlConnectionFactory.CreateConnectionOptions(String connectionString, DbConnectionOptions previous) 
 at System.Data.ProviderBase.DbConnectionFactory.GetConnectionPoolGroup(DbConnectionPoolKey key, DbConnectionPoolGroupOptions poolOptions, DbConnectionOptions& userConnectionOptions) at System.Data.SqlClient.SqlConnection.ConnectionString_Set(DbConnectionPoolKey key) at System.Data.SqlClient.SqlConnection.set_ConnectionString(String value) 
 at System.Data.Entity.Infrastructure.Interception.DbConnectionDispatcher.<SetConnectionString>b__1a(DbConnection t...</Data> 
    </EventData>
</Event>
Run Code Online (Sandbox Code Playgroud)

请注意,堆栈跟踪的末尾被截断为"...".

c# windows windows-services event-log

5
推荐指数
1
解决办法
702
查看次数

Azure上的事件日志中的错误事件50000780,它们是什么意思?

在我的Azure网站的事件日志中,我每1-5分钟看到相同的错误:

1 [varies]
5
50000780
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

这个错误信息是什么意思?先感谢您!

azure event-log azure-web-sites

5
推荐指数
1
解决办法
1952
查看次数

在Azure中使用事件日志(在事件查看器中写入)

我的网站用ASP.NET编写,我使用EventLog将日志写入事件查看器.它已在生产中运行(操作系统:Windows Server 2012 R2),并且在记录某些错误时没有遇到任何问题.我现在计划将服务器迁移到Azure - App Services.我想知道我的代码在记录错误后是否仍然可以移动到Azure - App Services?如果是,那么我如何查看我的网站记录的错误?我无法在Azure - App Services中看到事件查看器.如果不是那么在记录错误时替换我的代码的最简单和最快的替代方法是什么?

这是我的代码:

public static void LogEventLog(string message, EventLogEntryType logType)
    {
        string source = AppConfig.ErrorEventViewerSource;

        // Since we can't prevent the app from terminating, log this to the event log. 
        CreateEventSource(source);

        // Create an EventLog instance and assign its source.
        EventLog myLog = new EventLog();
        myLog.Source = source;
        myLog.WriteEntry(message, logType);

    }



    public static void CreateEventSource(string source)
    {
        if (!EventLog.SourceExists(source))
        {
            EventLog.CreateEventSource(source, "Application");
        }
    }
Run Code Online (Sandbox Code Playgroud)

c# asp.net azure event-log event-viewer

5
推荐指数
1
解决办法
1530
查看次数