Skip to main content
Documentation & User Guides | Fotoware

Writing the event log to a database

This is a step-by-step guide on how to configure the Fotoware log service to write entries to a SQL database.

About the logs

By default, the log files are written to C:\ProgramData\Fotoware\Log Files
The current log file is called FWEvents.log.  In the History folder at the same location as mentioned above you can find old log files. A new log file is created every day or when the log's file size exceeds 500 MB.

The log file is written in NLog format, so any NLog viever with log tailing functionality can be used to tail events that are written to the log. In some instances, however, it may make sense to write the Fotoware events to a database. The way to configure this is described below.

Preparing your database server

Before configuring the log server, you will need to prepare your database server. In this example we will use the default SQL that comes with FotoWeb.
To be able to set this up at all, you will need a database management tool. For example ‘Microsoft SQL Server Management Studio’ (you will need a full Microsoft SQL version to get this tool).

  1. Start by creating a new database. You can for instance call it FWLog.
  2. Next, create the necessary tables. To do so, write this query to the new database:
         (EventID INT IDENTITY(1,1) NOT NULL,
          Application VARCHAR(50) NOT NULL,
          EventCode VARCHAR(50) NOT NULL,
          Date VARCHAR(50) NOT NULL,
          Time VARCHAR(50) NOT NULL,
          Message VARCHAR(Max) NOT NULL,
          Computer VARCHAR(50) NOT NULL,
          UserName VARCHAR(50) NOT NULL,
          FileName VARCHAR(255) NOT NULL,
          FilePath VARCHAR(255) NOT NULL,
          FileObjectName VARCHAR(255) NOT NULL, 

Make sure the name you specify on the first line is the name of the database you've created.
Next, it's time to set up the log server.

Configuring the log server

The configuration file for the log server is located at: C:\Program Files (x86)\Fotoware\Log Server 7.0
 The file is called nlog.config and basically is an XML file.
Open the nlog.config file in a text editor. Then, inside the <targets> node add the following (below the last <target> node):

<target name="database" xsi:type="Database"> 
             insert into FWLog(application,eventcode,date,time,message,computer,username,filename,filepath,fileobjectname) values (@application,@eventcode,@date,@time,@message,@computer,@username,@filename,@filepath,@fileobjectname); 
       <parameter name="@application" layout="${event-context:item=Application}" />
       <parameter name="@eventcode" layout="${event-context:item=EventCode}" />
       <parameter name="@date" layout="${shortdate}" />
       <parameter name="@time" layout="${date:format=HH}:${date:format=mm}:${date:format=ss}:${date:format=fff}" />
       <parameter name="@message" layout="${message}" />
       <parameter name="@computer" layout="${event-context:item=Computer}" />
       <parameter name="@userName" layout="${event-context:item=UserName}" />
       <parameter name="@filename" layout="${event-context:item=FileName}" />
       <parameter name="@filepath" layout="${event-context:item=Path}" />
       <parameter name="@fileobjectname" layout="${event-context:item=ObjectName}" />

Apply these changes to the above tags

In the <dbhost> tag, you will need to enter the name of your SQL server.

In the <dbdatabase> tag, write the name of the database you created earlier.

<dbusername> and <dbpassword> should contain your ‘sa’-user's username and password.

Then inside the <rules> tag, add the following:

<logger name="*" minlevel="Trace" appendTo="database"/>

Restart all Fotoware services

Now, restart all Fotoware services (including the Operations Center and the Fotoware log server), and the events will be logged to the database.

Tip: To easily stop all Fotoware services on a server, simply stop the Fotoware Log Service. Since all the other services depend on this service, they will all be stopped gracefully.

  • Was this article helpful?