Skip to content

Tips and tricks

vytis edited this page Aug 23, 2012 · 6 revisions

NSLogger tips and tricks

Regular expressions

Filters allow you to match entries containing text that matches regular expressions. For this, your filter must use the matches clause and you should bracket your regex with .* on both sides of the text, like in the example below.


When debugging software, one frequently needs to set marks in the log at various points to identify action sections (for example, place a mark in the log before pushing a button, to visualize the logs generated by the button action). To this end, NSLogger allows you to add a mark at the end of the log. Select Add Mark (Cmd-M) in the action menu at bottom of the window to quickly add a time-stamped mark. Use Add Mark With Title (shift-Cmd-M) to customize the title that will appear in the log window.

XCode 4 Integration

To have NSLogger getting started too when your app gets started just enter ‘Edit Scheme’ and add a ‘Run Script’ to the ‘Pre-Actions’ of ‘Run’. The script to run should look like this:

open -g -a NSLogger

If you want to start not only for specific projects you may want to have a look at the very powerful ‘Behaviours’.

Working in a team with multiple loggers

When working in a team you need to take care that logs would be transmitted only to your machine. To set everything up:

  • Add
    to the ‘Preprocessor Macros’ in the project’s build settings. Make sure to add it only for debug mode. It creates a constant LOGGER_TARGET that contains your current (short) username.
  • Add these lines in application:didFinishLaunchingWithOptions::
    #ifdef LOGGER_TARGET
        LoggerSetupBonjour(NULL, NULL, (CFStringRef)LOGGER_TARGET);

    This configures the default logger to send messages to bonjour service named LOGGER_TARGET.
  • In the NSLogger application preferences set bonjour service name to your current username.
Something went wrong with that request. Please try again.