瀏覽代碼

添加日志监控

user_lt 1 年之前
父節點
當前提交
b588619905

+ 5 - 0
BlankApp1/BlankApp1/NLog.config

@@ -25,9 +25,14 @@
 		<target xsi:type="Console"
 				name="logConsole"
 				layout="${varLayHeader}|${varLayMiddle}|${varLayBack}" />
+		<target xsi:type="NlogViewer" name="ctrl" />
 	</targets>
 	<rules>
 		<logger minlevel="Trace" name="*" writeTo="logFile" />
 		<logger minlevel="Trace" name="*" writeTo="logConsole" />
+		<logger minlevel="Trace" name="*"  writeTo="ctrl" />
 	</rules>
+	<extensions>
+		<add assembly="NlogViewer" />
+	</extensions>
 </nlog>

+ 2 - 0
BlankApp1/BlankApp1/PLCTool.csproj

@@ -22,6 +22,8 @@
     <PackageReference Include="MiniExcel" Version="1.31.2" />
     <PackageReference Include="NLog" Version="5.2.5" />
     <PackageReference Include="NLog.Extensions.Logging" Version="5.3.5" />
+    <PackageReference Include="NLog.Wpf.RichTextBox" Version="1.0.2" />
+    <PackageReference Include="NlogViewer" Version="0.7.0" />
     <PackageReference Include="Prism.DryIoc" Version="8.1.97" />
     <PackageReference Include="SqlSugarCore" Version="5.1.4.113" />
     <PackageReference Include="System.Configuration.ConfigurationManager" Version="7.0.0" />

+ 10 - 4
BlankApp1/BlankApp1/Views/MonitorManageView/LogView.xaml

@@ -4,22 +4,28 @@
              xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
              xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
              xmlns:local="clr-namespace:PLCTool.Views.MonitorManageView"
+                 xmlns:nlog ="clr-namespace:NlogViewer;assembly=NlogViewer"
              mc:Ignorable="d" 
              d:DesignHeight="450" d:DesignWidth="800">
+    <!--<UserControl.Resources>
+        <Style TargetType="nlog:NlogViewer">
+        
+        </Style>
+    </UserControl.Resources>-->
     <Grid>
         <Grid.RowDefinitions>
             <RowDefinition Height="60"/>
             <RowDefinition/>
         </Grid.RowDefinitions>
         <StackPanel  Grid.Row="0" Orientation="Horizontal">
-            <Button  Content="开始监控"   Margin="5,0"  Command="{Binding QueryCommand}" Style="{StaticResource NormalButtonStyle}" />
+            <Button  Content="开始监控"   Margin="5,0"  Command="{Binding StartCommand}" Style="{StaticResource NormalButtonStyle}" />
             <Button  Content="停止监控"   Margin="5,0"  Command="{Binding QueryCommand}" Style="{StaticResource NormalButtonStyle}" />
             <Button  Content="清理Log"   Margin="5,0"  Command="{Binding QueryCommand}" Style="{StaticResource NormalButtonStyle}" />
         </StackPanel>
         <StackPanel Grid.Row="1">
-            <ListBox>
-
-            </ListBox>
+            <nlog:NlogViewer x:Name="logCtrl" Background="Transparent"  TimeWidth="120" LoggerNameWidth="100" LevelWidth="80" MessageWidth="200" ExceptionWidth="120">
+             
+            </nlog:NlogViewer>
         </StackPanel>
     </Grid>
 </UserControl>