REad content from Log file

Dani_S 3,206 Reputation points
2024-07-03T07:22:47.6+00:00

Hi,

I want to read this value, how is done?

C:\GssdDesktopClient\Logs\GssdDesktopClient.log"

<?xml version="1.0" encoding="utf-8" ?>

<configuration>


<configSections>

	<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net"/>

</configSections>

<log4net>



<appender name="console" type="log4net.Appender.ConsoleAppender">

	<layout type="log4net.Layout.PatternLayout">

		<conversionPattern value="%date %level %logger - %message%newline" />

	</layout>

</appender>

<appender name="file" type="log4net.Appender.RollingFileAppender">

		<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />

	<file type="log4net.Util.PatternString" value="%property{LogFileName}.txt" />

	<file value="C:\GssdDesktopClient\Logs\GssdDesktopClient.log" />

	<appendToFile value="true" />

	<rollingStyle value="Size" />

	<maxSizeRollBackups value="5" />

	<maximumFileSize value="25MB" />

	<staticLogFileName value="true" />

	<layout type="log4net.Layout.PatternLayout">

		<conversionPattern value="%date [%thread] %level %logger - %message%newline" />

	</layout>

	<filter type="log4net.Filter.LoggerMatchFilter">

		<loggerToMatch value="Microsoft.Maui.Controls.Xaml.Diagnostics.BindingDiagnostics" />

		<acceptOnMatch value="false" />

	</filter>

</appender>

	<root>

		<level value="INFO" />


	

		<!--<appender-ref ref="console" />-->

		<appender-ref ref="file" />

	</root>
</log4net>

</configuration>

.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
3,143 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Wenyan Zhang (Shanghai Wicresoft Co,.Ltd.) 28,631 Reputation points Microsoft Vendor
    2024-07-04T06:49:52.24+00:00

    Hello,

    It is on Windows platform, and you know the file path, right? If so, please refer to the following code:

    #if WINDOWS
    string path = "C:\\Users\\XX\\Documents\\GssdDesktopClient.log";// I new a file to test
    var text = File.ReadAllText(path);
    #endif
    

    Best Regards,

    Wenyan Zhang


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.