Posts

Implement Logging in Sql Server Database using Nlog in .net core MVC application - part 3

Image
In previous article " Implement Logging in CSV file using Nlog in .net core MVC application- part 2 "  I have demonstrated that how we can implement Logging in CSV file using Nlog in .core mvc application. In previous article I have logged the exceptions in CSV file, in this article I will show you how you can store the exception and custom logs in SQL server database using Nlog in .net core MVC application. Storing logs in SQL server database can help us to query the exception data efficiently and we can show it to UI if needed to check exception upfront.      Lets start the implementation of it, I going to use the same example project used in previous article/demonstration. The following nuget package needs to be installed before implement the sql server logging using NLog.   "Microsoft.Data.SqlClient" Version="3.0.1" "NLog" Version="4.7.13"  "NLog.Config" Version="4.7.13" "NLog.Extensions.Logging" Versio

Solved- goto option of notepad disabled

Image
I am using notepad most of time for easy way to store text of my day to day job.  But suddenly I am not able to use the go to functionality of note pad to move to specific line no. In notepad to enable goto option you need to check and act on below things. Go to format menu and check word wrap option is on or not If it is on then keep it off so that goto option will enable again. This is what the solution you can use for disable goto functionality.

Implement Logging in CSV file using Nlog in .net core MVC application- part 2

Image
In previous article " Implement Nlog in .Net core MVC application part 1 "  I have demonstrated how we can implement basic setup of NLog in .core mvc application. In previous article we have logged the exceptions in flat file system. In this article I will show you how you can write the exception and custom logs in csv file. Writing logs in csv file can enable us better readability of logs in tabular form.       Lets start the implementation of it, I going to use the same example project used in previous demonstration. Modify the Nlog.config file as follows, added new target and rule for logging logs in csv file. <?xml version="1.0" encoding="utf-8" ?> <nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd" autoReload="true" throwExceptions="fal

Implement Nlog in .Net core MVC application part 1

Image
Logging is a very important part of the enterprise application/web application. Setting up the logging correctly not only beneficial for long term maintenance of the application but also it is useful tool to find out the RCA in case of mission critical bug arises. Therefor we will going to discuss the various logging technique implementation using Nlog library package. In this article we will going to use .net core application for demonstration but you can implement it in .net framework application also. So lets start the implementation of Nlog in .net core MVC application. Open visual studio 2019/17 and create the new project as shown below.     Select Asp.net core Web App (Model-View-Controller) and provide the project name in project name text box.   Now on next screen click on create button this will create MVC app with .net core Now go to solution explorer and right click on project and click on Manage Nuget Package. Now in Nuget package manager install below listed Nlog packages.

Disable backspace key using Jquery

Disable backspace key in HTML form using Jquery in simple steps. While user enters data into application if user accidentally  press backspace button then it will redirect to previous page and all entered data would be lost. to eliminate this event we can disable the backspace key using Jquery. Following is the JQuery script tag you can add to the web page $(document).keydown(function (e) { var nodeName = e.target.nodeName.toLowerCase(); if (e.which === 8) { if ((nodeName === 'input' && e.target.type === 'text') || nodeName === 'textarea') { // do nothing } else { e.preventDefault(); } } }); The above code can be used seamlessly with any web technology you are using. Hope this will help you in your web application. Happy coding:)