<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Serilog | Learn C Games Programming Blog</title>
	<atom:link href="https://learncgames.com/tag/serilog/feed/" rel="self" type="application/rss+xml" />
	<link>https://learncgames.com</link>
	<description>A blog about C, programming games and my ebook(s).</description>
	<lastBuildDate>Mon, 07 Mar 2022 11:22:16 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://learncgames.com/wp-content/uploads/2020/03/cropped-favicon-32x32.png</url>
	<title>Serilog | Learn C Games Programming Blog</title>
	<link>https://learncgames.com</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">181446779</site>	<item>
		<title>More Programming Joys</title>
		<link>https://learncgames.com/more-programming-joys/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=more-programming-joys</link>
					<comments>https://learncgames.com/more-programming-joys/#comments</comments>
		
		<dc:creator><![CDATA[David]]></dc:creator>
		<pubDate>Tue, 08 Mar 2022 00:00:48 +0000</pubDate>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Graphics]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[Serilog]]></category>
		<category><![CDATA[Skia]]></category>
		<guid isPermaLink="false">https://learncgames.com/?p=3021</guid>

					<description><![CDATA[<p>So I&#8217;ve been doing some .NET programming. First on Windows because I can debug it there then &#8220;Publish it&#8221; which puts all the files (compiled in release) needed, including any dlls into one folder and upload it to a VPS using WinSCP. I&#8217;ve also got a terminal session connected by Putty. I use Serilog for [&#8230;]</p>
The post <a href="https://learncgames.com/more-programming-joys/">More Programming Joys</a> first appeared on <a href="https://learncgames.com">Learn C Games Programming Blog</a>.]]></description>
										<content:encoded><![CDATA[<div class='__iawmlf-post-loop-links' style='display:none;' data-iawmlf-post-links='[{&quot;id&quot;:63,&quot;href&quot;:&quot;https:\/\/serilog.net&quot;,&quot;archived_href&quot;:&quot;http:\/\/web-wp.archive.org\/web\/20260103212351\/https:\/\/serilog.net\/&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-02-06 11:28:57&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-10 04:39:36&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-14 10:25:44&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-17 14:30:37&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-21 04:35:54&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-24 12:51:47&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-28 00:38:48&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-03 20:03:58&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-07 18:33:19&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-12 00:39:19&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-16 00:37:33&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-19 22:43:09&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-23 11:58:53&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-26 20:35:23&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-31 00:31:33&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-03 10:33:20&quot;,&quot;http_code&quot;:200}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-04-03 10:33:20&quot;,&quot;http_code&quot;:200},&quot;process&quot;:&quot;done&quot;},{&quot;id&quot;:64,&quot;href&quot;:&quot;https:\/\/github.com\/serilog\/serilog&quot;,&quot;archived_href&quot;:&quot;http:\/\/web-wp.archive.org\/web\/20251216014112\/https:\/\/github.com\/serilog\/serilog&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-02-06 11:29:00&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-10 00:39:46&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-13 02:24:18&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-16 18:55:22&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-21 08:35:50&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-24 12:51:48&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-28 00:38:52&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-03 20:03:56&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-07 18:33:18&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-12 00:39:19&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-16 00:37:32&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-19 22:43:08&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-23 11:58:58&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-26 20:35:26&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-31 00:31:35&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-03 10:33:19&quot;,&quot;http_code&quot;:206}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-04-03 10:33:19&quot;,&quot;http_code&quot;:206},&quot;process&quot;:&quot;done&quot;},{&quot;id&quot;:65,&quot;href&quot;:&quot;https:\/\/stackoverflow.com\/questions\/44428405\/i-am-using-net-core-with-c-sharp-on-linux-lib-system-drawing-is-missing&quot;,&quot;archived_href&quot;:&quot;http:\/\/web-wp.archive.org\/web\/20181104053240\/https:\/\/stackoverflow.com\/questions\/44428405\/i-am-using-net-core-with-c-sharp-on-linux-lib-system-drawing-is-missing&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-02-06 11:29:02&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-10 20:36:02&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-15 01:01:48&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-19 00:40:52&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-22 19:08:18&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-27 04:24:13&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-03 00:39:27&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-06 10:44:08&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-09 17:23:49&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-14 00:37:02&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-18 00:39:33&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-22 00:32:31&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-26 00:55:13&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-30 00:39:20&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-02 20:46:52&quot;,&quot;http_code&quot;:200}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-04-02 20:46:52&quot;,&quot;http_code&quot;:200},&quot;process&quot;:&quot;done&quot;},{&quot;id&quot;:66,&quot;href&quot;:&quot;https:\/\/github.com\/mono\/SkiaSharp\/issues\/1341&quot;,&quot;archived_href&quot;:&quot;http:\/\/web-wp.archive.org\/web\/20250109034858\/https:\/\/github.com\/mono\/SkiaSharp\/issues\/1341&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-02-06 11:29:05&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-10 10:18:17&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-14 12:39:11&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-17 14:30:43&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-21 16:38:54&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-26 04:32:15&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-02 04:40:31&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-05 17:31:19&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-08 18:37:14&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-12 06:24:43&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-16 00:37:35&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-19 22:43:28&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-23 11:59:04&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-26 20:35:20&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-31 00:31:33&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-03 10:33:21&quot;,&quot;http_code&quot;:206}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-04-03 10:33:21&quot;,&quot;http_code&quot;:206},&quot;process&quot;:&quot;done&quot;}]'></div>
<p><img decoding="async" class="alignleft size-full wp-image-3023" src="https://learncgames.com/wp-content/uploads/2022/03/map.jpg" alt="Game Map" width="100" height="100" />So I&#8217;ve been doing some .NET programming. First on Windows because I can debug it there then &#8220;Publish it&#8221; which puts all the files (compiled in release) needed, including any dlls into one folder and upload it to a VPS using WinSCP. I&#8217;ve also got a terminal session connected by Putty. I use Serilog for logging and SkiaSharp for graphics.</p>
<p>First bug was a missing file but it was a stupid error on my part. I had the file in a path under the home folder and had used ~ in the file&#8217;s path. You can use ~ in Bash- it means your home folder, but not in a file path in an application. Putting in the full path fixed the bug. D&#8217;oh.</p>
<p>Because it&#8217;s .NET (6) that I&#8217;m using, you don&#8217;t get configuration stuff the same as you did with .NET Framework. I store some config information in a file and define the path with these lines of code which work on both Linux and Windows.</p>
<pre><code class="language-csharp" data-line=""> bool IsWindows =&gt; RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
 var appSettingsFilePath = IsWindows ? @&quot;c:\turfwar\twConfig.json&quot; : &quot;/home/user/turfwar/twConfig.json&quot;;</code></pre>
<p>I like <a title="Link to serilog website" href="https://serilog.net/" target="_blank" rel="noopener">Serilog</a> ( with project on <a title="Link to Serilog on GitHub" href="https://github.com/serilog/serilog" target="_blank" rel="nofollow noopener">Github</a> at ). Nice and simple logging but flexible enough. As this application is a command line app run whenever, it&#8217;s easier to view the logs afterwards.</p>
<h2>Why use SkiaSharp?</h2>
<p>I was quite happy to use System.Drawing but <a title="Link to StackOverflow question about .NET Core on Linux" href="https://stackoverflow.com/questions/44428405/i-am-using-net-core-with-c-sharp-on-linux-lib-system-drawing-is-missing" target="_blank" rel="nofollow noopener">according to this</a>, There are issues with libgdiplus. So I thought I&#8217;d try SkiaSharp as I&#8217;m doing stuff with Flutter and Skia is the library that underpins that. This is what it takes to create a 100 x100 grey coloured Bitmap in SkiaSharp, add yellow dots and save it to disk as a .jpg. That&#8217;s what you see up above.</p>
<pre><code class="language-csharp" data-line="">        internal void SaveBitMap(int id, string filename, Gang gang)
        {
            var info = new SKImageInfo(100, 100);
            using var surface = SKSurface.Create(info);
            SKCanvas myCanvas = surface.Canvas;

            // clear the canvas / fill with white
            myCanvas.DrawColor(new SKColor(0x99, 0x99, 0x99));

            // draw the dots, one for each block
            foreach (var block in Blocks)
            {
                if (block.Owner == id)
                {
                    myCanvas.DrawPoint(block.X*5/2, block.Y*5/2, SKColors.Yellow);
                }
            }

            // Now save to filename
            var mainCanvasImage = surface.Snapshot();
            var TempTIFbitmap1 = SKBitmap.Decode(mainCanvasImage.Encode());
            using (var image = SKImage.FromBitmap(TempTIFbitmap1))
            using (var data = image.Encode(SKEncodedImageFormat.Jpeg, 100))
            {
                // save the data to a stream
                using (var stream = File.OpenWrite(filename))
                {
                    data.SaveTo(stream);
                }
            }
        }</code></pre>
<p>It works fine on Windows but on Linux, (Ubuntu 20.04) I hit bug #2. &#8220;System.TypeInitializationException: The type initializer for &#8216;SkiaSharp.SKImageInfo&#8217; threw an exception.&#8221;. And that&#8217;s where I am at the moment.  <a title="Link to Bug discussion for SkiaSharp" href="https://github.com/mono/SkiaSharp/issues/1341" target="_blank" rel="nofollow noopener">This</a> is similar.  I&#8217;ll keep you informed.</p>The post <a href="https://learncgames.com/more-programming-joys/">More Programming Joys</a> first appeared on <a href="https://learncgames.com">Learn C Games Programming Blog</a>.]]></content:encoded>
					
					<wfw:commentRss>https://learncgames.com/more-programming-joys/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">3021</post-id>	</item>
	</channel>
</rss>
