尝试获取类型的实例激活出错日志写进程 [英] Activation error occured while trying to get instance of type LogWriter

查看:188
本文介绍了尝试获取类型的实例激活出错日志写进程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用企业库5.0的应用程序日志使用的块登录简单的信息赢得XP SP3系统上的Windows事件日志:



Logger.Write (MSG);



我在尝试登录时的错误消息,同时试图让类型日志写的情况下发生激活错误的



任何帮助调试这个问题表示赞赏。



下面显示的是与MS企业库


所使用的配置文件

 <?XML版本=1.0编码=UTF-8>?; 
<结构>
< configSections>
<节名称=loggingConfigurationTYPE =Microsoft.P​​ractices.EnterpriseLibrary.Logging.Configuration.LoggingSettings,Microsoft.P​​ractices.EnterpriseLibrary.Logging,版本= 5.0.414.0,文化=中性公钥= 31bf3856ad364e35requirePermission =真/>
< / configSections>
< loggingConfiguration NAME =tracingEnabled =真defaultCategory =常规>​​;
<&听众GT;
<添加名称=事件日志监听器类型=Microsoft.P​​ractices.EnterpriseLibrary.Logging.TraceListeners.FormattedEventLogTraceListener,Microsoft.P​​ractices.EnterpriseLibrary.Logging,版本= 5.0.414.0,文化=中性公钥= 31bf3856ad364e35
listenerDataType =Micr​​osoft.P​​ractices.EnterpriseLibrary.Logging.Configuration.FormattedEventLogTraceListenerData,Microsoft.P​​ractices.EnterpriseLibrary.Logging,版本= 5.0.414.0,文化=中性公钥= 31bf3856ad364e35
源=企业库记录格式化=文本格式化
日志=应用程序MACHINENAME =。 traceOutputOptions =无/>
< /听众>
<格式化>
<加上TYPE =Microsoft.P​​ractices.EnterpriseLibrary.Logging.Formatters.TextFormatter,Microsoft.P​​ractices.EnterpriseLibrary.Logging,版本= 5.0.414.0,文化=中性公钥= 31bf3856ad364e35
模板= 时间戳:{时间戳} {换行符}&放大器; #xA;消息:{消息} {换行符}&放大器; #xA;类别:{类别} {换行符}&放大器; #xA;优先级:{优先权} {换行符}&安培; #xA;事件ID:{事件ID} {}换行和放大器; #xA;严重性:{严重} {}换行和放大器; #xA;标题是:{title} {}换行和放大器; #xA;机:{LOCALMACHINE} {}换行符&安培; #xA;应用程序域:{localAppDomain} {换行符}&放大器; #xA;的ProcessID:{localProcessId} {换行符}&放大器; #xA;进程名称:{localProcessName} {换行符}&放大器; #xA;螺纹名称:{ threadName} {换行符}&放大器; #xA;的Win32的ThreadId:{win32ThreadId} {换行符}&放大器; #xA;扩展属性:{字典({键} - {值} {换行符})}
NAME =文本格式化/>
< /格式化>
< categorySources>
<添加switchValue =全部NAME =常规>​​;
<&听众GT;
<添加名称=事件日志监听器/>
< /听众>
< /添加>
< / categorySources>
< specialSources>
< allEvents switchValue =全部NAME =所有事件/>
< notProcessed switchValue =全部NAME =未处理类别/>
<错误switchValue =全部NAME =记录错误和放大器;放大器;警告>
<&听众GT;
<添加名称=事件日志监听器/>
< /听众>
< /错误>
< / specialSources>
< / loggingConfiguration>
< /结构>


解决方案

我只是想添加这个错误的原因可能另一个配置问题。请一定要看看这个错误的内部异常。在我的情况是:



。该型数据库无法构造必须配置为提供此值的容器



要解决此我不得不添加一个的providerName 以在web.config我的数据库连接字符串。所以最终的连接字符串节点是这样的:

 <添加名称=DBConn的connectionString =数据源=服务器;初始目录=记录;坚持安全信息= TRUE;集成安全=真;的providerName =System.Data.SqlClient的/> 


I am trying to using the Logging Application block of Enterprise Library 5.0 to log simple message to the Windows event log on Win XP SP3 system using:

Logger.Write(msg);

I get the "Activation error occured while trying to get instance of type LogWriter" error message when trying to log.

Any help to debug this issue is appreciated.

Shown below is the config file used with MS Enterprise library

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
    <section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
</configSections>
<loggingConfiguration name="" tracingEnabled="true" defaultCategory="General">
    <listeners>
        <add name="Event Log Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FormattedEventLogTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
            listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FormattedEventLogTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
            source="Enterprise Library Logging" formatter="Text Formatter"
            log="Application" machineName="." traceOutputOptions="None" />
    </listeners>
    <formatters>
        <add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
            template="Timestamp: {timestamp}{newline}&#xA;Message: {message}{newline}&#xA;Category: {category}{newline}&#xA;Priority: {priority}{newline}&#xA;EventId: {eventid}{newline}&#xA;Severity: {severity}{newline}&#xA;Title:{title}{newline}&#xA;Machine: {localMachine}{newline}&#xA;App Domain: {localAppDomain}{newline}&#xA;ProcessId: {localProcessId}{newline}&#xA;Process Name: {localProcessName}{newline}&#xA;Thread Name: {threadName}{newline}&#xA;Win32 ThreadId:{win32ThreadId}{newline}&#xA;Extended Properties: {dictionary({key} - {value}{newline})}"
            name="Text Formatter" />
    </formatters>
    <categorySources>
        <add switchValue="All" name="General">
            <listeners>
                <add name="Event Log Listener" />
            </listeners>
        </add>
    </categorySources>
    <specialSources>
        <allEvents switchValue="All" name="All Events" />
        <notProcessed switchValue="All" name="Unprocessed Category" />
        <errors switchValue="All" name="Logging Errors &amp; Warnings">
            <listeners>
                <add name="Event Log Listener" />
            </listeners>
        </errors>
    </specialSources>
</loggingConfiguration>
</configuration>

解决方案

I just wanted to add this error may be caused by another configuration issue. Make sure to look at the inner exceptions for this error. In my case it was:

"The type Database cannot be constructed. You must configure the container to supply this value."

To resolve this I had to add a providerName to my database connection string in the web.config. So the final connection string node looked like this:

 <add name="DBConn" connectionString="Data Source=ServerName;Initial Catalog=Logging;Persist Security Info=True;integrated security=True;" providerName="System.Data.SqlClient" />

这篇关于尝试获取类型的实例激活出错日志写进程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆