是否可以使用Log4Perl将所有消息/级别直接登录到OutputDebugString (Windows )?
我有一些已经使用log4perl的模块,但是现在我想在一个所有日志消息都是OutputDebugStrings的环境中使用这些模块--在这个环境中,消息用DbgView读取,我想用DbgView读取模块的输出。我不想将Log4Perl日志文件与DbgView输出合并。
我使用以下Perl代码直接从perl编写OutputDebugStrings:
use Win32::API::OutputDebugString qw(OutputDebugString DStr);
OutputDebugString("Foo bar", "baz\n"); # sends Foo barbaz\n to the debugger我找到了log4net.Appender.OutputDebugStringAppender --如何在Perl上实现相同的功能?
提前谢谢。
发布于 2013-07-25 12:32:45
====找到了一个====解决方案,多亏了达辛姆,我写了自己的附录。这是来源
使用以下代码-generate一个perl包
package Log4PerlOutputDebugStringAppender;
sub new {
my($class, %options) = @_;
my $self = { %options };
bless $self, $class;
return $self;
}
sub log {
my($self, %params) = @_;
use Win32::API::OutputDebugString qw(OutputDebugString DStr);
OutputDebugString( "$params{message}" );
}
1;使用以下内容-generate一个Log4Perl配置文件
log4perl.logger = INFO, OutputDebugString
log4perl.appender.OutputDebugString=Log4PerlOutputDebugStringAppender
log4perl.appender.OutputDebugString.layout=Log::Log4perl::Layout::PatternLayout
log4perl.appender.OutputDebugString.layout.ConversionPattern=[%-5p] %-15.15c{1} (%4L) - %m%n-initialize脚本中的记录器
use Log::Log4perl qw(:easy);
Log::Log4perl->init("logconf.txt");
INFO("INFO");
WARN("WARN");
FATAL("FATAL");Età-所有日志记录消息都通过OutputDebugStrings
谢谢达辛姆的帮助。
https://stackoverflow.com/questions/17813963
复制相似问题