发布时间:2025-12-09 16:15:32 浏览次数:5
在C#中调用该方法
[DllImport("kernel32.dll", CharSet = CharSet.Auto)]public static extern void OutputDebugString(string message);System.Diagnostics.Trace.WriteLine也可以实现和OutputDebugString类似的效果
测试代码如下
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Runtime.InteropServices;namespace DebugViewTest{ class Program { [DllImport("kernel32.dll", CharSet = CharSet.Auto)] public static extern void OutputDebugString(string message); static void Main(string[] args) { Console.WriteLine("BEGIN"); for (int i = 0; i < 10; i++) { OutputDebugString("debugstring"); System.Diagnostics.Trace.WriteLine("tracestring"); } Console.WriteLine("END"); } }}运行测试程序,查看DebugView的日志列表
DebugView会默认连接到 本机local
在C#中调用时不管编译的是Debug还是Release都是能正常捕获的
远程调试需要在本地和远程机器上都启动DebugView进程
远程机器作为接收请求的一端,需要在命令行下加参数启动 ,即 dbgview /a
可以使用 tasklist /fi “imagename eq dbgview.exe” 命令得到dbgview的进程id
再结合 netstat -ano | find 命令找到dbgview监听的端口
如图所示,dbgview默认监听2020端口
本机作为请求的一端,可以通过菜单栏的 “Connect” 按钮连接到远程的DebugView
需要先断开到本地的默认连接
1.服务进程监控
DebugView默认捕获应用层普通的win32应用程序,菜单栏默认 勾选 “Capture Win32”
如果被监控进程是以windows服务形式存在的,那么需要使用管理员权限启动DebugView进程
然后在DebugView菜单栏勾选 “Capture Global Win32”
勾选 "Capture Kernel"会对内核的日志输出进行捕获
2.一些服务器防火墙开启的情况下,需要对dbgview监听的端口进行放行