Apr 23, 2008

Writing Log to Text File with C#

Writing Text File with C#

 

Problem definition : I need to write this for logging for testing purpose. I am logging the information when a aspx file is being called,

I want to put all information like browser, os, resolution, referer page etc.

 

So here we goes

I like to add a method let it call LogToFile()

Don't forget to include #using System.IO; as we are going to use stream writer

protected void LogToFile()

    {

            string logFilePath = Server.MapPath("Trace.txt");

        StreamWriter sw = new StreamWriter(logFilePath, true);

        //true means if file not there then create it otherwise append to it.

        try

        {

            sw.WriteLine("Logging Time: " + DateTime.Now.ToLongDateString());

            sw.WriteLine("OS/Browser/Version : "+Request.Browser.Platform.ToString()+"/" +Request.Browser.Browser.ToString()+ “/"+Request.Browser.Version.ToString());

           

            if (Request.UrlReferrer != null)

            {

                sw.WriteLine("Referrer: "+ Request.UrlReferrer.ToString());

            }

            sw.WriteLine("User Agent: " + Request.UserAgent.ToString());

            sw.WriteLine("--------------------------------------------------------");

        }

        catch(Exception )

        {

        }

        finally

        {

            if (sw != null)

            {

                sw.Close();

            }

        } 

    }

Now call this function into pageload method of your page... you will get the trace.

You can add more properties/ information according to your needs.

Apr 22, 2008

Enable pinging - Ping worker process every ( 30 seconds)

Application Pools setting

 

Enable pinging – Ping worker process every (frequency in seconds)

This setting specifies that each worker process will be pinged every n seconds, where n is the number specified in the selection box. This process is used to determine if a worker process is running correctly, or if it has been deadlocked.

What it mean ?

Central to Health monitoring is process pinging. With process pinging, IIS periodically checks to see if worker processes are responsive. This means that the WWW Service (svchost.exe) sends a ping request at a specified interval to each worker process (w3wp.exe). If a worker process fails to respond to the ping request, either because it doesn’t have additional threads available for processing incoming requests or because it’s hung up, the WWW Service flags the worker process as unhealthy. If the worker process is in an idle but unresponsive state, the WWW Service terminates it immediately and a replacement worker process is created. Otherwise, the worker process is marked for recycling.

 

Apr 17, 2008

Free Tax Calculator 2008 2009 India

In my previous post I could not upload the Tax Calculator, Here I did it and posted it again.

Please get if from HERE

Note this is for salaried personal only.

Tips on Filling your Vehicles

This is a Message received from a friend:

I don't know what you guys are paying for petrol... but here in Durban, we are also paying higher, up to 47.35 per litre. But my line of work is in petroleum for about 31 years now, so here are some tricks to get more of your money's worth for every litre.

Here at the Marian Hill Pipeline, where I work in Durban, we deliver about 4 million litres in a 24-hour period thru the pipeline.

One day is diesel; the next day is jet fuel, and petrol, LRP and Unleaded. We have 34-storage tanks here with a total capacity of 16,800,000 litres.

ONLY BUY OR FILL UP YOUR CAR OR BIKKIE IN THE EARLY MORNING WHEN THE GROUND TEMPERATURE IS STILL COLD. Remember that all service stations have their storage tanks buried below ground. The colder the ground, the denser the fuel, when it gets warmer petrol expands, so buying in the afternoon or in the evening.... your litre is not exactly a litre.

In the petroleum business, the specific gravity and the temperature of the petrol, diesel and jet fuel, ethanol and other petroleum products play an important role. A 1degree rise in temperature is a big deal for this business. But the service stations do not have temperature compensation at the pumps.

WHEN YOU'RE FILLING UP, DO NOT SQUEEZE THE TRIGGER OF THE NOZZLE TO A FAST MODE. If you look, you will see that the trigger has three (3) stages: low, middle, and high. In slow mode, you should be pumping on low speed, thereby minimizing the vapours that are created, while you are pumping. All hoses at the pump have a vapour return. If you are pumping on the fast rate, some of the liquid that goes to your tank becomes vapour. Those vapours are being sucked up and back into the underground storage tank so you're getting less worth for your money.

ONE OF THE MOST IMPORTANT TIPS IS TO FILL UP WHEN YOUR TANK IS HALF FULL. The reason for this is, the more fuel you have in your tank, the less air occupying its empty space. Petrol evaporates faster than you can imagine. Petroleum storage tanks have an internal floating roof. This roof serves as zero clearance between the petrol and the atmosphere, so it minimizes the evaporation.

Unlike service stations, here where I work, every truck that we load is temperature compensated, so that every litre is actually the exact amount.

ANOTHER REMINDER, IF THERE IS A FUEL TRUCK PUMPING INTO THE STORAGE TANKS, WHEN YOU STOP TO BUY, DO NOT FILL UP - most likely the petrol/diesel is being stirred up as the fuel is being delivered, and you might pick up some of the dirt that normally settles on the bottom.

Hope, this will help you get the maximum value for your money.

DO SHARE THESE TIPS WITH OTHERS! LET’S SHARE INFORMATION AND BENEFIT ALL, FOR THE BETTER OF MANKIND.

Apr 11, 2008

A wonderful message for all who misuse their work phone : Joke

Phone Bill

The phone bill was exceptionally high and the man of the house called a family meeting...

Dad: People this is unacceptable. You have to limit the use of the phone. I do not use this phone, I use the one at the office.

Mum: Same here, I hardly use this home telephone as I use my work telephone

Son: Me too, I never use the home phone. I always use my company mobile

Maid: I know I am the one to be blamed but  what is the problem? We all use our work telephones.

 

 

Apr 3, 2008

TAX Calculator for Financial Year 2008 - 2009

A quick tax calculator by Economics Times for year 2008 - 2009.

Please get it from here

Note: Only for employed person only

Apr 1, 2008

Linked bloggers

Blogger List

At this page I wish to see a lot of information about blogs and their links.

Please write comment to add you blog here.

Computers & Internet

http://matespoint.blogspot.com Technical hurdles while development.

http://uiautomation.blogspot.com All about UI Automation information.

Education

http://up-results.blogspot.com Search Results, CPMT 2008, UP Board 2008 etc.

Fun and Entertainment

www.techieshangout.blogspot.com
http://worldofinfotainment.blogspot.com
http://rahul-games-movies.blogspot.com

http://teentweens.blogspot.com/

Personal

http://mohanitguy.blogspot.com
http://varunkrishna.blogspot.com
http://freakers-digest.blogspot.com/
www.sarv007.blogspot.com
http://mhkharish.blogspot.com
http://www.supershiva.blogspot.com
http://www.versatilecollection.blogspot.com
http://www.supershiva.blogspot.com

http://www.versatilecollection.blogspot.com

IT Technologies

http://itbuddy.blogspot.com
http://www.tech4logic.blogspot.com
www.goldnvk.blogspot.com
www.techieshangout.blogspot.com
http://theblogresource.blogspot.com
http://javabugger.blogspot.com
www.techieshangout.blogspot.com

Others

http://trusted-money-making-sites-for-asians.blogspot.com/

Note: These links remain there until you have this page into your blog. This applies for all, no discrepancy. If anybody wants to include his/her blog @ this page. He / She needs to include this page link into his/her page and leave a comment with his/her blog along the Category in which blog should be placed.

SQL - Difference between CAST,CONVERT and PARSE

TODO---