<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: log code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Wed, 21 May 2008 22:44:23 GMT</pubDate>
    <description>DZone Snippets: log code</description>
    <item>
      <title>disable SQL / MySQL in rails logging in development mode</title>
      <link>http://snippets.dzone.com/posts/show/4727</link>
      <description>// description of your code here&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;ActiveRecord::Base.logger = Logger.new("#{RAILS_ROOT}/log/#{RAILS_ENV}_database.log")&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;goes at end of config/env</description>
      <pubDate>Fri, 02 Nov 2007 00:09:50 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4727</guid>
      <author>jm3 (john manoogian III)</author>
    </item>
    <item>
      <title>Rake task to clear Rails log files</title>
      <link>http://snippets.dzone.com/posts/show/4458</link>
      <description>&lt;code&gt;&lt;br /&gt;# Truncates all *.log files in log/ to zero bytes&lt;br /&gt;rake log:clear&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Fri, 24 Aug 2007 13:19:34 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4458</guid>
      <author>sikelianos (Zeke Sikelianos)</author>
    </item>
    <item>
      <title>Add rails log to console</title>
      <link>http://snippets.dzone.com/posts/show/4371</link>
      <description>In order to show rails log in console, add theses lines to your .irbrc&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;if ENV.include?('RAILS_ENV')&amp;&amp; !Object.const_defined?('RAILS_DEFAULT_LOGGER')&lt;br /&gt;  Object.const_set('RAILS_DEFAULT_LOGGER', Logger.new(SDTOUT))&lt;br /&gt;end&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Tue, 31 Jul 2007 11:16:56 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4371</guid>
      <author>Mickael (Mickael)</author>
    </item>
    <item>
      <title>C#: Log A Message To A File</title>
      <link>http://snippets.dzone.com/posts/show/4334</link>
      <description>&lt;code&gt;&lt;br /&gt;// Put this at the top&lt;br /&gt;using System.IO;&lt;br /&gt;//&lt;br /&gt;&lt;br /&gt;public static void Log(string Message)&lt;br /&gt;{&lt;br /&gt;	File.AppendAllText(HttpContext.Current.Server.MapPath("~") + "/log.txt", DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString() + ": " + Message + Environment.NewLine);&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Thu, 19 Jul 2007 22:46:26 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4334</guid>
      <author>cornerblue (CornerBLUE, Inc.)</author>
    </item>
    <item>
      <title>Debug logs in the database</title>
      <link>http://snippets.dzone.com/posts/show/4077</link>
      <description>How to log things in the database&lt;br /&gt;&lt;br /&gt;Create the table:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;create table TMP_LOG (HORA date, ENTRADA varchar(4000));&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;Write the things I need to the table:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;INSERT INTO TMP_LOG (HORA, ENTRADA) VALUES(SYSDATE, &lt;br /&gt;  'V_NOM_DESTINATARIO1: '||V_NOM_DESTINATARIO1||', V_DOM_DESTINATARIO1: '||V_DOM_DESTINATARIO1||&lt;br /&gt;  ', P_NOM_DESTINATARIO_2: '||P_NOM_DESTINATARIO_2||', P_DOM_DESTINATARIO_2: '||P_DOM_DESTINATARIO_2||&lt;br /&gt;  ', B_DESTINATARIO: '||B_DESTINATARIO||&lt;br /&gt;  ', V_NOM_DESTINATARIO2: '||V_NOM_DESTINATARIO2||', V_DOM_DESTINATARIO2: '||V_DOM_DESTINATARIO2);&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;Consult the things written:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;select * from tmp_log order by hora desc;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;Dont forget to drop it at the end:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;drop table TMP_LOG;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;</description>
      <pubDate>Wed, 30 May 2007 16:59:19 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4077</guid>
      <author>koke24 (Koke)</author>
    </item>
    <item>
      <title>convert apache http combined logs into sql (and import it into a mysql database eventually)</title>
      <link>http://snippets.dzone.com/posts/show/3721</link>
      <description>you need to extract the data in your http server log files and put it in a database to query it with your usual tools using SQL. this perl script does just this.&lt;br /&gt;&lt;br /&gt;it was hard to find it, that's why i put it here.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;#!/usr/bin/perl -w&lt;br /&gt;# Written by Aaron Jenson.&lt;br /&gt;# Original source: http://www.visualprose.com/software.php&lt;br /&gt;# Updated to work under Perl 5.6.1 by Edward Rudd&lt;br /&gt;# Updated 24 march 2007 by Slim Amamou &lt;slim.amamou@alpha-studios.com&gt;&lt;br /&gt;#  - output SQL with the option '--sql'&lt;br /&gt;#  - added SQL create table script to the HELP&lt;br /&gt;#&lt;br /&gt;#  NOTE : you need the TimeDate library (http://search.cpan.org/dist/TimeDate/)&lt;br /&gt;#&lt;br /&gt;use strict;&lt;br /&gt;use Getopt::Long qw(:config bundling);&lt;br /&gt;use DBI;&lt;br /&gt;use Date::Parse;&lt;br /&gt;&lt;br /&gt;my %options = ();&lt;br /&gt;my $i = 0;&lt;br /&gt;my $sql = '';&lt;br /&gt;my $valuesSql = '';&lt;br /&gt;my $line = '';&lt;br /&gt;my $dbh = 0;&lt;br /&gt;my $sth = 0;&lt;br /&gt;my @parts = ();&lt;br /&gt;my $part;&lt;br /&gt;my $TIMESTAMP = 3;&lt;br /&gt;my $REQUEST_LINE = 4;&lt;br /&gt;my @cols = (&lt;br /&gt;	'remote_host',			## 0&lt;br /&gt;	'remote_logname',		## 1&lt;br /&gt;	'remote_user',			## 2&lt;br /&gt;	'request_time',			## 3.string&lt;br /&gt;	'time_stamp',			## 3.posix&lt;br /&gt;	'request_line',			## 5&lt;br /&gt;	'request_method',		## 6&lt;br /&gt;	'request_uri',			## 7&lt;br /&gt;	'request_args',			## 8&lt;br /&gt;	'request_protocol',		## 9&lt;br /&gt;	'status',				## 10&lt;br /&gt;	'bytes_sent',			## 11&lt;br /&gt;	'referer',				## 12&lt;br /&gt;	'agent'					## 13&lt;br /&gt;);&lt;br /&gt;my $col = '';&lt;br /&gt;&lt;br /&gt;GetOptions (\%options,&lt;br /&gt;		"version" =&gt; sub { VERSION_MESSAGE(); exit 0; },&lt;br /&gt;		"help|?" =&gt; sub { HELP_MESSAGE(); exit 0; },&lt;br /&gt;		"host|h=s",&lt;br /&gt;		"database|d=s",&lt;br /&gt;		"table|t=s",&lt;br /&gt;		"username|u=s",&lt;br /&gt;		"password|p=s",&lt;br /&gt;		"logfile|f=s",&lt;br /&gt;		"sql");&lt;br /&gt;&lt;br /&gt;$options{host} ||= 'localhost';&lt;br /&gt;$options{database} ||= '';&lt;br /&gt;$options{username} ||= '';&lt;br /&gt;$options{password} ||= '';&lt;br /&gt;$options{logfile} ||= '';&lt;br /&gt;$options{sql} ||= '';&lt;br /&gt;&lt;br /&gt;if( ! ($options{database} || $options{sql}))&lt;br /&gt;{&lt;br /&gt;	HELP_MESSAGE();&lt;br /&gt;	print "Must supply a database to connect to.\n";&lt;br /&gt;	exit 1;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;if( ! $options{table} )&lt;br /&gt;{&lt;br /&gt;	HELP_MESSAGE();&lt;br /&gt;	print "Must supply table name.\n";&lt;br /&gt;	exit 1;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;if( $options{logfile} )&lt;br /&gt;{&lt;br /&gt;	if( ! -e $options{logfile} )&lt;br /&gt;	{&lt;br /&gt;		print  "File '$options{logfile}' doesn't exist.\n";&lt;br /&gt;		exit 1;&lt;br /&gt;	}&lt;br /&gt;	open(STDIN, "&lt;$options{logfile}") || die "Can't open $options{logfile} for reading.";&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;if( $options{database} )&lt;br /&gt;{&lt;br /&gt;	$dbh = Connect();&lt;br /&gt;	if (! $dbh) {&lt;br /&gt;		exit 1;&lt;br /&gt;	}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;$sql = "INSERT INTO $options{table} (";&lt;br /&gt;foreach $col (@cols)&lt;br /&gt;{&lt;br /&gt;	$sql .= "$col," if( $col );&lt;br /&gt;}&lt;br /&gt;chop($sql);&lt;br /&gt;$sql .= ') VALUES (';&lt;br /&gt;my ($linecount,$insertcount) = (0,0);&lt;br /&gt;while($line = &lt;STDIN&gt;)&lt;br /&gt;{&lt;br /&gt;	$linecount++;&lt;br /&gt;	@parts = SplitLogLine( $line );&lt;br /&gt;	next if( $parts[$TIMESTAMP+1] == 0 );&lt;br /&gt;	$valuesSql = '';&lt;br /&gt;	for( $i = 0; $i &lt; @cols; ++$i )&lt;br /&gt;	{&lt;br /&gt;		$parts[$i] =~ s/\\/\\\\/g;&lt;br /&gt;		$parts[$i] =~ s/'/\\'/g;&lt;br /&gt;		$valuesSql .= "'$parts[$i]'," if( $cols[$i] );&lt;br /&gt;	}&lt;br /&gt;	chop($valuesSql);&lt;br /&gt;&lt;br /&gt;	if( $options{database} )&lt;br /&gt;	{&lt;br /&gt;		$sth  = $dbh-&gt;prepare("$sql$valuesSql)");&lt;br /&gt;		if( ! $sth-&gt;execute() )&lt;br /&gt;		{&lt;br /&gt;			print "Unable to perform specified query.\n$sql$valuesSql\n" . $sth-&gt;errstr() . "\n";&lt;br /&gt;		} else {&lt;br /&gt;			$insertcount++;&lt;br /&gt;		}&lt;br /&gt;		$sth-&gt;finish();&lt;br /&gt;	}&lt;br /&gt;	if( $options{sql} )&lt;br /&gt;	{&lt;br /&gt;		print "$sql$valuesSql);\n";&lt;br /&gt;	}&lt;br /&gt;}&lt;br /&gt;if( ! $options{sql} )&lt;br /&gt;{&lt;br /&gt;	print "Parsed $linecount Log lines\n";&lt;br /&gt;	print "Inserted $insertcount records\n";&lt;br /&gt;	print "to table '$options{table}' in database '$options{database}' on '$options{host}'\n";&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # &lt;br /&gt;# Connects to a MySQL database and returns the connection.&lt;br /&gt;# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # &lt;br /&gt;sub Connect&lt;br /&gt;{&lt;br /&gt;	my $dsn = "DBI:mysql:$options{database};hostname=$options{host}";&lt;br /&gt;	return DBI-&gt;connect( $dsn, $options{username}, $options{password} );&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # &lt;br /&gt;# Splits up a log line into its parts.&lt;br /&gt;# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # &lt;br /&gt;sub SplitLogLine&lt;br /&gt;{&lt;br /&gt;	my $line = shift;&lt;br /&gt;	my $i = 0;&lt;br /&gt;	my $inQuote = 0;&lt;br /&gt;	my $char = '';&lt;br /&gt;	my $part = '';&lt;br /&gt;	my @parts = ();&lt;br /&gt;	my $count = 0;&lt;br /&gt;	chomp($line);&lt;br /&gt;	for( $i = 0; $i &lt; length($line); ++$i )&lt;br /&gt;	{&lt;br /&gt;		$char = substr($line, $i, 1);&lt;br /&gt;		if( $char eq ' ' &amp;&amp; ! $inQuote )&lt;br /&gt;		{&lt;br /&gt;			## print "Found part $part.\n";&lt;br /&gt;			if( $count == $TIMESTAMP )&lt;br /&gt;			{&lt;br /&gt;				push(@parts, "[".$part."]");&lt;br /&gt;				$part = str2time($part);&lt;br /&gt;			}&lt;br /&gt;			push(@parts, $part);&lt;br /&gt;			if( $count == $REQUEST_LINE )&lt;br /&gt;			{&lt;br /&gt;				my @request = split(/[ ?]/, $part);&lt;br /&gt;				push(@parts, $request[0]);&lt;br /&gt;				push(@parts, $request[1]);&lt;br /&gt;				if( $request[3] )&lt;br /&gt;				{&lt;br /&gt;					push(@parts, $request[2]);&lt;br /&gt;					push(@parts, $request[3]);&lt;br /&gt;				}&lt;br /&gt;				else&lt;br /&gt;				{&lt;br /&gt;					push(@parts, '');&lt;br /&gt;					push(@parts, $request[2]);&lt;br /&gt;				}&lt;br /&gt;				$count += 5;&lt;br /&gt;			}&lt;br /&gt;			else&lt;br /&gt;			{&lt;br /&gt;				++$count;&lt;br /&gt;			}&lt;br /&gt;			$part = '';&lt;br /&gt;		}&lt;br /&gt;		elsif( $char eq '"' || $char eq '[' || $char eq ']' )&lt;br /&gt;		{&lt;br /&gt;			$inQuote = !$inQuote;&lt;br /&gt;		}&lt;br /&gt;		else&lt;br /&gt;		{&lt;br /&gt;			$part .= $char;&lt;br /&gt;		}&lt;br /&gt;	}&lt;br /&gt;	push(@parts,$part) if $part;&lt;br /&gt;&lt;br /&gt;	return @parts;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # &lt;br /&gt;# Prints the usage/help message for this program.&lt;br /&gt;# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # &lt;br /&gt;sub HELP_MESSAGE&lt;br /&gt;{&lt;br /&gt;	print&lt;&lt;EOF;&lt;br /&gt;Imports an Apache combined log into a MySQL database.&lt;br /&gt;Usage: mysql_import_combined_log.pl -d &lt;database name&gt; -t &lt;table name&gt; [-h &lt;hostname&gt;] [-u &lt;username&gt;] [-p &lt;password&gt;] [-f &lt;filename]&lt;br /&gt; --host|-h &lt;host name&gt;         The host to connect to.  Default is localhost.&lt;br /&gt; --database|-d &lt;database name&gt; The database to use.  Required.&lt;br /&gt; --username|-u &lt;username&gt;      The user to connect as.&lt;br /&gt; --password|-p &lt;password&gt;      The user's password.&lt;br /&gt; --table|-t &lt;table name&gt;       The name of the table in which to insert data.&lt;br /&gt; --logfile|-f &lt;file name&gt;      The file to read from.  If not given, data is read from stdin.&lt;br /&gt; --sql                         Output SQL&lt;br /&gt; --help|-?                     Print out this help message.&lt;br /&gt; --version                     Print out the version of this software.&lt;br /&gt;&lt;br /&gt;----------------------------------&lt;br /&gt;-- SQL create statements for the table&lt;br /&gt;--&lt;br /&gt;&lt;br /&gt;create table &lt;TABLE_NAME&gt; (&lt;br /&gt;    remote_host varchar(50) ,&lt;br /&gt;    remote_logname varchar(50) ,&lt;br /&gt;    remote_user varchar(50) ,&lt;br /&gt;    request_time char(28),&lt;br /&gt;    time_stamp varchar(10) ,&lt;br /&gt;    request_line varchar(255),&lt;br /&gt;    request_method varchar(10) ,&lt;br /&gt;    request_uri varchar(255),&lt;br /&gt;    request_args varchar(255),&lt;br /&gt;    request_protocol varchar(10) ,&lt;br /&gt;    status varchar(10) ,&lt;br /&gt;    bytes_sent varchar(10) ,&lt;br /&gt;    referer varchar(255) ,&lt;br /&gt;    agent varchar(255)&lt;br /&gt;);&lt;br /&gt;&lt;br /&gt;EOF&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # &lt;br /&gt;# Prints the version information for this program&lt;br /&gt;# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # &lt;br /&gt;sub VERSION_MESSAGE&lt;br /&gt;{&lt;br /&gt;	print "mysql_import_combined_log.pl version 1.2\n";&lt;br /&gt;	print "Version 1.0 Written by Aaron Jenson.\n";&lt;br /&gt;	print "Update to work with perl 5.6.1 by Edward Rudd\n";&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;1;&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Sat, 24 Mar 2007 10:40:53 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/3721</guid>
      <author>slim (Slim Amamou)</author>
    </item>
    <item>
      <title>Active Record log</title>
      <link>http://snippets.dzone.com/posts/show/3402</link>
      <description>from &lt;http://weblog.jamisbuck.org/2007/1/31/more-on-watching-activerecord&gt;&lt;br /&gt;&lt;br /&gt;In config/environment.rb:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;def log_to(stream)&lt;br /&gt;  ActiveRecord::Base.logger = Logger.new(stream)&lt;br /&gt;  ActiveRecord::Base.clear_active_connections!&lt;br /&gt;end&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;then in the console :&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&gt;&gt; log_to STDOUT&lt;br /&gt;=&gt; ...&lt;br /&gt;&gt;&gt; Post.find(:first)&lt;br /&gt;  Post Load (0.000138)   SELECT * FROM posts LIMIT 1&lt;br /&gt;=&gt; #&lt;Post:0x1234 ...&gt;&lt;br /&gt;&gt;&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;The best part is, by clearing the active connections after setting the logger, you can change the logger at any time, even after you&#8217;ve made any number of find calls.&lt;br /&gt;&lt;br /&gt;And, you can pass your own stream objects into it:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&gt;&gt; buffer = StringIO.new&lt;br /&gt;=&gt; ...&lt;br /&gt;&gt;&gt; log_to buffer&lt;br /&gt;=&gt; ...&lt;br /&gt;&gt;&gt; Post.find(:first)&lt;br /&gt;=&gt; #&lt;Post:0x1234 ...&gt;&lt;br /&gt;&gt;&gt; p buffer.string&lt;br /&gt;=&gt; "  \e[4;35;1mPost Load (0.000138)\e[0m   \e[0mSELECT * FROM posts LIMIT 1\e[0m\n"&lt;br /&gt;&gt;&gt;&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Thu, 01 Feb 2007 13:45:53 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/3402</guid>
      <author>Mickael (Mickael)</author>
    </item>
    <item>
      <title>links for debugging javascript</title>
      <link>http://snippets.dzone.com/posts/show/2490</link>
      <description>// description of your code here&lt;br /&gt;&lt;br /&gt;Loggers&lt;br /&gt;&lt;a href="http://www.bigbold.com/snippets/posts/show/2443"&gt;my simple logger&lt;/a&gt;&lt;br /&gt;&lt;a href="http://mochikit.com/doc/html/MochiKit/Logging.html"&gt;MochiKit logger&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Online interpreters&lt;br /&gt;&lt;a href="http://www.squarefree.com/shell/shell.html"&gt;Squarefree JS shell 1.4&lt;/a&gt;&lt;br /&gt;&lt;a href="http://mochikit.com/examples/interpreter/index.html"&gt;MochiKit JS interactive interpreter&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.w3schools.com/js/tryit.asp?filename=tryjs_bodysection"&gt;TryIt Editor&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;debugging bookmarklets&lt;br /&gt;&lt;a href="http://javascript.about.com/library/blsource.htm"&gt;view source&lt;/a&gt;&lt;br /&gt;&lt;a href="http://my.opera.com/community/dev/jsdebug/"&gt;linked scripts list&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;// insert code here..&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Tue, 29 Aug 2006 14:34:58 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/2490</guid>
      <author>em3zh3 (Doc Aha)</author>
    </item>
    <item>
      <title>logging bookmarklets for debugging javascript</title>
      <link>http://snippets.dzone.com/posts/show/2443</link>
      <description>Dragg the following two links to your browser's toolbar (tested with Firefox 1.5 and IE 6) :&lt;br /&gt;&lt;a href="javascript:(function(){log49 = [];})()"&gt;49.cl&lt;/a&gt;&lt;br /&gt;&lt;a href="javascript:(function(){alert(log49.join('\n-=-=-=-=-=\n'));})()"&gt;49.sh&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;When you are writing some javascript embedded in a webpage and you want to debug your code, this gives you way to log things without alerting them. &lt;br /&gt;&lt;br /&gt;Example :&lt;br /&gt;&lt;code&gt;&lt;br /&gt;// part of embedded javascript code&lt;br /&gt;log49 = [];//log49 is global variable.&lt;br /&gt;var num = 1;&lt;br /&gt;log49.push('num = '+num); // log the state of num&lt;br /&gt;num = num+1;&lt;br /&gt;log49.push('second num ='+num); // again.&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Then the two bookmarklets let you reset or view the log in runtime.&lt;br /&gt;49.cl lets you reset the log by clearing the list stored in the global variable log49.&lt;br /&gt;49.sh shows you the log by joining and alerting the value of log49.&lt;br /&gt;</description>
      <pubDate>Sat, 19 Aug 2006 01:37:57 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/2443</guid>
      <author>em3zh3 (Doc Aha)</author>
    </item>
    <item>
      <title> Adding Comments to the IIS Log</title>
      <link>http://snippets.dzone.com/posts/show/2158</link>
      <description> Adding Comments to the IIS Log&lt;br /&gt;&lt;br /&gt;A simple way to provide more information to the IIS log files is to append it yourself with the Response.AppendToLog method. By using Session and Application events you can place keywords that you can later use when search the files. You might even be able to train some of the analysis programs to understand you keywords and hopefully provide more meaningful stats.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;    Sub Application_BeginRequest(ByVal sender As Object, ByVal e As EventArgs)&lt;br /&gt;        ' Fires at the beginning of each request&lt;br /&gt;        Response.AppendToLog("test")&lt;br /&gt;    End Sub&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;There are some restrictions, however. Since the data you provide is appended to the URI Query portion of the log file, you are limited to 80 characters. In addition, you cannot use commas since they are a delimiter for some of the log file formats. Also, if you anticipate that there will be other querystring elements you may want to prepend your string with an ampersand. &lt;br /&gt;&lt;br /&gt;----&lt;br /&gt;&lt;br /&gt;From http://psacake.com/web/ht.asp:&lt;br /&gt;While trying to come up with new ways to record things that are happening on my Web server, I came across the Response Objects AppendToLog Method. This method allows you to write directly to the IIS Log File using only one line of code. This has come in handy for error trapping and troubleshooting. The following is a piece of sample code that writes a single entry to the log file:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;     Response.AppendToLog "Database Being Accessed"&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;The above line would write the following to your IIS log file:&lt;br /&gt;&lt;br /&gt;127.0.0.1, -, 01/01/00, 12:00:34, W3SVC1,WEBSERVER, &lt;br /&gt;127.0.0.1, 161342, 485, 228, 200, 0, get, /somefile.asp, Database Being Accessed&lt;br /&gt;&lt;br /&gt;Remember that the IIS log file is a comma-delimited file, and you should try to avoid using commas in the data string you pass to the log file.&lt;br /&gt;&lt;br /&gt;----&lt;br /&gt;&lt;br /&gt;Rant From http://sqljunkies.com/WebLog/ktegels/archive/2004/01/21/795.aspx:&lt;br /&gt;Since we already have IIS logging turned on, it just made sense to log to that. When we needed to harvest the data for making test case, we could just parse the logs. So, I turned a hopeful eye towards HttpResponse.AppendToLog (which is available to us in ASP.NET as Response.AppendToLog) thinking it might at least be a Copper Bullet. It works, but, where it decides to put your entry in the log could be a problem. Data written to these logs using this method is inserted where the cs-uri-query field would be rather than at the end of the record.&lt;br /&gt;&lt;br /&gt;I suppose that this behavior makes sense if you stop to consider that the cs-uri-query field should be blank, null or otherwise meaningless for POSTs (normally). Of course, the de facto RFC doesn't say that, so IIS can get by with it.&lt;br /&gt;&lt;br /&gt;Unless of course, you're GETting, not POSTing. But in those cases, you really don't need this trick anyway.&lt;br /&gt;&lt;br /&gt;My whole problem with this that the "Extended Log File Format" does offer a more proper place to put this data: x-Comment. If X-Comment appeared at the end of a line, it likely wouldn't break most log parsers, and we'd have a sensible place to look for this.</description>
      <pubDate>Wed, 07 Jun 2006 22:45:11 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/2158</guid>
      <author>MattScilipoti (Matt Scilipoti)</author>
    </item>
  </channel>
</rss>
