惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Google DeepMind News
Google DeepMind News
Stack Overflow Blog
Stack Overflow Blog
Hugging Face - Blog
Hugging Face - Blog
博客园_首页
T
The Blog of Author Tim Ferriss
博客园 - 叶小钗
N
Netflix TechBlog - Medium
腾讯CDC
C
Check Point Blog
P
Proofpoint News Feed
Engineering at Meta
Engineering at Meta
GbyAI
GbyAI
S
SegmentFault 最新的问题
F
Fortinet All Blogs
美团技术团队
U
Unit 42
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
博客园 - 司徒正美
F
Full Disclosure
Recorded Future
Recorded Future
D
DataBreaches.Net
博客园 - 【当耐特】
Martin Fowler
Martin Fowler
J
Java Code Geeks
I
InfoQ
Y
Y Combinator Blog
A
About on SuperTechFans
AI
AI
爱范儿
爱范儿
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Forbes - Security
Forbes - Security
W
WeLiveSecurity
M
MIT News - Artificial intelligence
雷峰网
雷峰网
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Simon Willison's Weblog
Simon Willison's Weblog
Schneier on Security
Schneier on Security
The GitHub Blog
The GitHub Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
aimingoo的专栏
aimingoo的专栏
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
G
GRAHAM CLULEY
Know Your Adversary
Know Your Adversary
Latest news
Latest news
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
D
Docker
Recent Commits to openclaw:main
Recent Commits to openclaw:main
量子位
V2EX - 技术
V2EX - 技术
Project Zero
Project Zero

博客园 - 皮皮@北京

自定义MOSS搜索框 最牛比的IE。。 微软于周一正式公布了下一个版本的SharePoint服务器版本的初步系统要求 讨厌的K2变化ProcessInstance.DataFields - 皮皮@北京 - 博客园 安装SQL Server 2008 及 VS 2008(转自邹建老大的blog) Windows SharePoint Services 3.0 通用参考中文版 Microsoft Office SharePoint Server 2007 通用参考中文版 避免Webpart Page的URL地址中带ID参数的问题 用js改变MOSS自带的一些按钮的默认事件 K2中的任务代理 [转]大学厕所里爆笑接龙(好久没更新了啊。。) 解决:K2.net Studio 遇到问题需要关闭 The Sharepoint 2007 Song WorkflowManagementHostServer Not Hosted! 用ddwrt:URLLookup在列表自定义页面中显示查阅项的链接 SharePoint Permissions Matrix 记录中心设置 如何给SPListItem中DateTime类型的Field赋空值 巨爆笑~
K2 BlackPearl中日志记录的设置与扩展
皮皮@北京 · 2008-06-16 · via 博客园 - 皮皮@北京

K2 BlackPearl的日志提供了多种方式来记录K2的信息,日志配置在C:\Program Files\K2 blackpearl\Host Server\Bin\HostServerLogging.config中,打开配置文件,可以看到下面的片段:

<ApplicationLevelLogSettings>
    
<ApplicationLevelLogSetting Scope="Default">
      
<LogLocationSettings>
        
<LogLocation Name="ConsoleExtension" Active="True" LogLevel="Debug" />
        
<LogLocation Name="FileExtension" Active="False" LogLevel="All" />
        
<LogLocation Name="EventLogExtension" Active="False" LogLevel="Debug" />
        
<LogLocation Name="ArchiveExtension" Active="False" LogLevel="Debug" />
        
<LogLocation Name="MSMQExtension" Active="False" LogLevel="Debug" />
      
</LogLocationSettings>
    
</ApplicationLevelLogSetting>
</ApplicationLevelLogSettings>

Name对应此config文件的Extensions节点中的Extension节点的Name属性,在下面可以看到。
Active控制是否使用此配置项,因此我们可以看出,默认情况下,K2只使用“ConsoleExtension”,也就
是控制台模式。
LogLevel控制日志的级别。为了看到更详细的信息,我们调节这个属性来实现,从简单到详细依
次是Warning->Error->Info->Debug->All

K2的调试:
在管理工具-服务中将K2服务停止,然后点击开始菜单的K2 blackpearl-K2 Server,此时K2会
以控制台模式来启动服务,K2的相关信息就可以方便的看到,在我们的代码中使用Console.WriteLine("message") 可以方便的输出到这里。

另外使用命令行"C:\Program Files\K2 blackpearl\Host Server\Bin\K2HostServer.exe" > c:\k2info.txt

可以将信息输出到c:\k2info.txtK2除了默认的集中记录日志的方式外,还让我们自己扩展实现自定义的记录方式,比如下面的片段:

<ApplicationLevelLogSettings>
    
<ApplicationLevelLogSetting Scope="Default">
      
<LogLocationSettings>
        
<LogLocation Name="ConsoleExtension" Active="False" LogLevel="Debug" />
        
<LogLocation Name="FileExtension" Active="False" LogLevel="All" />
        
<LogLocation Name="EventLogExtension" Active="False" LogLevel="Debug" />
        
<LogLocation Name="ArchiveExtension" Active="False" LogLevel="Debug" />
        
<LogLocation Name="MSMQExtension" Active="False" LogLevel="Debug" />
      
</LogLocationSettings>
    
</ApplicationLevelLogSetting>
   
<ApplicationLevelLogSetting Scope="SourceCode.Security.UserRoleManager.Runtime.UserRoleManagerServer">
    
<LogLocationSettings>
<LogLocation Name="ConsoleExtension" Active="True" LogLevel="Error" />
</LogLocationSettings>
</ApplicationLevelLogSetting>
</ApplicationLevelLogSettings>

我们可以看到,这里有两个ApplicationLevelLogSetting节点,不同的是两个ApplicationLevelLogSetting的Scope不同。具体情形我还没有具体尝试,抱歉,因为这样的扩展实现的效果非常有限。下面具体来说下另外一种方式的扩展:
在HostServerLogging.config,找到Extensions节点,可以看到这样的配置:

<Extensions>
    
<Extension Name="ConsoleExtension" type="SourceCode.Logging.Extension.ConsoleExtension">
      
<Property Name="Shorthand" value="true"/>
    
</Extension>
    
<Extension Name="EventLogExtension" type="SourceCode.Logging.Extension.EventLogExtension" />
    
<Extension Name="FileExtension" type="SourceCode.Logging.Extension.FileExtension">
      
<Property Name="LogFileName" value="HostServer.log"/>
      
<Property Name="LogFilePath" value="" />
      
<Property Name="HashAlgorithm" value="CRC32" />
    
</Extension>
    
<Extension Name="MSMQExtension" type="SourceCode.Logging.Extension.MSMQExtension">
      
<Property Name="QueuePath" value=".\private$\SCQueue"/>
    
</Extension>
    
<Extension Name="ArchiveExtension" type="SourceCode.Logging.Extension.ArchiveExtension">
            
<Property Name="HostServerConfigFileName" value="K2HostServer.config"/>
      
<Property Name="ConfigDBConnectionName" value="HostserverDB"/>
    
</Extension>
  
</Extensions>


在这里我们可以清楚的看到第一段XML中的ConsoleExtension,FileExtension,EventLogExtension等节点的Name是从哪里来的了。在这里我们来添加自己的扩展配置,例如发送Email。首先我们编写自定义扩展的代码,继承BaseExtension,只需重写一个方法

using System;
using SourceCode.Logging;
using SourceCode.Logging.Extension;
using System.Net.Mail;
namespace LoggerExtension
{
    
public class Email : BaseExtension
    
{
        
public Email()
        
{
        }

        
override protected void LogMessage(MessageObject mo, String logStrMsg)
        
{
            
try
            
{
               
//send email
            }

            
catch
            
{
                
throw;
            }

            
return;
        }

    }

}


看得出来,非常简单 :)
然后在上面所示的Extensions节点中加入自定义扩展的一个节点

<Extension Name="EmailExtension" type="LoggerExtension.Email" location="C:\LoggerExtension.dll"></Extension>


type是我们扩展代码dll的namespace.class,location是这个dll的所在位置。

对应着LogLocationSettings节点中也加入一个节点,注意两个Name要匹配.

<LogLocation Name="EmailExtension" Active="True" LogLevel="All" />


最后保存config文件,一个日志记录的扩展设置就OK了。