Firemonkey IFMXLoggingService Windows事件日志位置 [英] Firemonkey IFMXLoggingService Windows Event Log Location
问题描述
我正在通过Log类(它使用IFMXLoggingService编写事件)来查看内置的FMX日志支持。我在iOS和Android中找到了日志文件位置的信息,但在Windows(8.1)上找不到任何内容。
I am looking at the FMX built in logging support via the Log class which uses the IFMXLoggingService to write events. I have found info for the log file location in iOS and Android but unable to find anything on Windows (8.1).
有人知道此服务写入哪个特定日志文件吗? ?
Does anyone know which specific log file this service writes to? and is this able to be changed in code or otherwise?
谢谢
推荐答案
如果您查看源代码,则会在 FMX.Platform.Win.TPlatformWin.Log
中找到实现:
If you look at the sources you will find the implementation at FMX.Platform.Win.TPlatformWin.Log
:
procedure TPlatformWin.Log(const Fmt: string; const Params: array of const);
begin
OutputDebugString(PChar(Format(Fmt, Params)));
end;
OutputDebugString()
不会向任何日志文件。当应用程序在调试器中运行时,它将记录到调试器的内置事件日志中。当应用在调试器之外运行时,第三方工具,例如 SysInternal DebugView 可以捕获这些消息。
OutputDebugString()
does not send messages to any log file at all. It logs to the debugger's built-in event log, when the app is running inside the debugger. When the app is running outside of the debugger, third-party tools like SysInternal DebugView can capture these messages.
如果要使用自定义记录器,请编写一个实现 IFMXLoggingService
接口并在运行时向FMX注册:
If you want to use a custom logger, write a class that implements the IFMXLoggingService
interface and register it with FMX at runtime:
type
TMyLoggingService = class(TInterfacedObject, IFMXLoggingService)
public
procedure Log(const Format: string; const Params: array of const);
end;
procedure TMyLoggingService.Log(const Format: string; const Params: array of const);
begin
// do whatever you want...
end;
var
MyLoggingService : IFMXLoggingService;
begin
MyLoggingService := TMyLoggingService.Create;
// if a service is already registered, remove it first
if TPlatformServices.Current.SupportsPlatformService( IFMXLoggingService ) then
TPlatformServices.Current.RemovePlatformService( IFMXLoggingService );
// now register my service
TPlatformServices.Current.AddPlatformService( IFMXLoggingService, MyLoggingService );
end;
您可以使用 TPlatformServices.AddPlatformService 和 TPlatformServices.RemovePlatformService 分别用于注册和取消注册平台服务。
You can use TPlatformServices.AddPlatformService and TPlatformServices.RemovePlatformService to register and unregister platform services, respectively.
例如,您可以注销其中一个内置平台服务,并用适合您需要的平台服务的新实现替换它。
For example, you can unregister one of the built-in platform services and replace it with a new implementation of the platform service that is tailored to fit your needs.
这篇关于Firemonkey IFMXLoggingService Windows事件日志位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!