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

推荐订阅源

Forbes - Security
Forbes - Security
T
Tailwind CSS Blog
Hugging Face - Blog
Hugging Face - Blog
Blog — PlanetScale
Blog — PlanetScale
WordPress大学
WordPress大学
aimingoo的专栏
aimingoo的专栏
Y
Y Combinator Blog
U
Unit 42
I
InfoQ
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
V
Visual Studio Blog
B
Blog RSS Feed
Vercel News
Vercel News
F
Fortinet All Blogs
Know Your Adversary
Know Your Adversary
T
Troy Hunt's Blog
博客园 - 【当耐特】
MongoDB | Blog
MongoDB | Blog
大猫的无限游戏
大猫的无限游戏
A
About on SuperTechFans
Jina AI
Jina AI
小众软件
小众软件
T
Threatpost
有赞技术团队
有赞技术团队
人人都是产品经理
人人都是产品经理
The Hacker News
The Hacker News
T
The Exploit Database - CXSecurity.com
C
CXSECURITY Database RSS Feed - CXSecurity.com
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Microsoft Azure Blog
Microsoft Azure Blog
Recent Announcements
Recent Announcements
酷 壳 – CoolShell
酷 壳 – CoolShell
Scott Helme
Scott Helme
B
Blog
腾讯CDC
Last Week in AI
Last Week in AI
P
Proofpoint News Feed
S
Schneier on Security
N
News and Events Feed by Topic
Microsoft Security Blog
Microsoft Security Blog
K
Kaspersky official blog
G
Google Developers Blog
T
Tor Project blog
PCI Perspectives
PCI Perspectives
S
Secure Thoughts
Google Online Security Blog
Google Online Security Blog
Latest news
Latest news
Google DeepMind News
Google DeepMind News
MyScale Blog
MyScale Blog
罗磊的独立博客

博客园 - 皮皮@北京

自定义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了。