Project DescriptionNHTrace is a tool for tracing sql commands executed by NHibernate with syntax highlighting.
DetailsNHTrace listen for events logged by log4net, so, in order to trace, first you need to configure log4net on the application where NHibernate executes the sql commands. An example of that configuration can be found
here.
NOTE: currently NHTrace only supports log4net MsmqAppender, for more information about how to configure Microsoft Message Queue and log4net MsmqAppender, please see Installing and configuring Microsoft Message Queue and log4net MsmqAppenderTo highlight the sql commands, NHTrace uses these two javascript libraries:
SHJSGoogle's PrettifyTo choose between them, change the "templatePath" key to the correct template.html file in the application configuration file (NHTrace.exe.config).
<add key="templatePath" value=".\Templates\shjs\template.html"/>
<!--<add key="templatePath" value=".\Templates\prettify\template.html"/>-->
Other libraries could be used,
here is a good list of different syntax highlighting libraries
FeaturesFunctions of the buttons in the toolbar
- Toggle logging on/off
- Clear log
- Refresh log
- Save log
- Toggle always on top on/off
- Toggle show process name on/off
- Toggle status bar visibility on/off
ConfigurationThis settings have to be configured on the NHTrace.exe.config file
<add key="logCharSize" value="20000"/>
<add key="templatePath" value=".\Templates\shjs\template.html"/>
<!--<add key="templatePath" value=".\Templates\prettify\template.html"/>-->
- logCharSize: amount of characters to show on the log (high values may cause some instability)
- templatePath: path (can be relative or absolute) to the template.html file used to render the messages with syntax highlighting
Updates
In this release the messages can be viewed in plain text and the sql commands can be copied with formatting, while you can choose to copy the command as it is or replace the parameter values inside the command as well. See screenshot below
- "Copy formatted sql" stores the following text in the clipboard
INSERT
INTO
"Product"
(Name, UnitPrice, Discontinued, Id)
VALUES
(@p0, @p1, @p2, @p3);
@p0 = 'Apple0', @p1 = 0.25, @p2 = False, @p3 = 1001
- "Copy sql and replace parameters" stores the following text in the clipboard
INSERT
INTO
"Product"
(Name, UnitPrice, Discontinued, Id)
VALUES
('Apple0', 0.25, False, 1001);
NOTE: multiple lines can be selected also
CreditsAuthor: Jorge Rowies
Google profile:
http://www.google.com/profiles/jorge.rowiesBlog:
http://jorgerowies.blogspot.com/Ohloh:
http://www.ohloh.net/accounts/jorgerowiesSome log4net receivers developed by Rémy Baudet in
Log2Console were modified to be used by NHTrace
Any feedback about this tool will be appreciated