<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Ahsanul Haque</title>
    <description>The latest articles on DEV Community by Ahsanul Haque (@ahaque98).</description>
    <link>https://dev.to/ahaque98</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1117324%2Fc15b4703-fa3c-4f3a-8735-f44155d9bbf4.jpeg</url>
      <title>DEV Community: Ahsanul Haque</title>
      <link>https://dev.to/ahaque98</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ahaque98"/>
    <language>en</language>
    <item>
      <title>What is LOGGING in .NET [8.0] MVC?</title>
      <dc:creator>Ahsanul Haque</dc:creator>
      <pubDate>Tue, 27 Feb 2024 19:54:06 +0000</pubDate>
      <link>https://dev.to/ahaque98/what-is-logging-in-net-80-mvc-part-1-36bf</link>
      <guid>https://dev.to/ahaque98/what-is-logging-in-net-80-mvc-part-1-36bf</guid>
      <description>&lt;p&gt;&lt;strong&gt;Logging&lt;/strong&gt; in &lt;strong&gt;.NET MVC&lt;/strong&gt; is a &lt;strong&gt;mechanism to track and record events&lt;/strong&gt; that occur while an application is running. It's a crucial aspect of software development for several reasons:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Debugging&lt;/strong&gt;: Logs provide detailed context about what the application was doing at a specific point in time. This information can be invaluable when trying to understand and fix bugs.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Monitoring&lt;/strong&gt;: By regularly reviewing logs, you can monitor the health of your application, identify patterns, detect anomalies, and spot potential issues before they become problems.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Auditing&lt;/strong&gt;: Logs can serve as an audit trail, providing a record of actions taken by users or the system itself. This can be important for security and compliance purposes.&lt;/p&gt;


&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In .NET MVC, you can use the built-in &lt;strong&gt;ILogger&lt;/strong&gt; interface for logging. This interface provides methods for logging at different levels of severity (Trace, Debug, Information, Warning, Error, Critical). &lt;/p&gt;

&lt;p&gt;Here's an example of how you might use it in a controller:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;HomeController&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Controller&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="k"&gt;readonly&lt;/span&gt; &lt;span class="n"&gt;ILogger&lt;/span&gt; &lt;span class="n"&gt;_logger&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;HomeController&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ILogger&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;HomeController&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;logger&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;_logger&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;logger&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="n"&gt;IActionResult&lt;/span&gt; &lt;span class="nf"&gt;Index&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;_logger&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;LogInformation&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Home/Index was called"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;View&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  In the example above,
&lt;/h2&gt;

&lt;p&gt;An &lt;strong&gt;ILogger&lt;/strong&gt; is &lt;strong&gt;injected&lt;/strong&gt; into the &lt;strong&gt;HomeController&lt;/strong&gt; through its constructor (this is done automatically by ASP.NET Core's dependency injection system). Then, in the Index action method, a log message is written at the Information level.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>webdev</category>
      <category>programming</category>
      <category>csharp</category>
    </item>
    <item>
      <title>N-Tier Architecture in asp.net core projects.</title>
      <dc:creator>Ahsanul Haque</dc:creator>
      <pubDate>Tue, 11 Jul 2023 07:19:01 +0000</pubDate>
      <link>https://dev.to/ahaque98/breaking-up-net-projects-44mi</link>
      <guid>https://dev.to/ahaque98/breaking-up-net-projects-44mi</guid>
      <description>&lt;h2&gt;
  
  
  Breaking up .NET projects into smaller pieces (N-TIER Architecture)
&lt;/h2&gt;




&lt;p&gt;&lt;strong&gt;Today i am going to be showing you how to implement N-Tier Architecture in your asp.net core projects&lt;/strong&gt; This is a project that i am doing to learn &lt;strong&gt;EntityFrameWorkCore&lt;/strong&gt;. You can have a look at my &lt;a href="https://github.com/ahaque98/Wiki_Coding" rel="noopener noreferrer"&gt;Github&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;This is the default project directory (MVC Project)&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2bpp4em47qie69seriv9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2bpp4em47qie69seriv9.png" alt="Image description" width="361" height="380"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;I have created different Class Library projects in the main Solution&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdesjs08p9bda09jqstvw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdesjs08p9bda09jqstvw.png" alt="Image description" width="357" height="410"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;The WikiCoding.DataAccess folder will be used for DataContext and Data Related stuffs. Eg, migration, table creation etc.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;I have moved the &lt;strong&gt;Models&lt;/strong&gt; folder to the &lt;strong&gt;WikiCoding_Models&lt;/strong&gt; folder.
&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmczft11tji206tubia0p.png" alt="Image description" width="358" height="446"&gt;
As you can see. I am breaking the projects into smaller pieces. This is the core principle of N-Tier Architecture. &lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>beginners</category>
      <category>tutorial</category>
      <category>csharp</category>
      <category>aspdotnet</category>
    </item>
  </channel>
</rss>
