

Last date modified: July 07 2025
The logging configuration services provide functionality for programmatically interacting with the Relativity logging framework. The following services update logging information stored on the EDDSLogging database:
You can use these services to simplify the setup of logging through the Relativity logging framework. For example, you may want to use these services when implementing a custom page or application that provides a UI for configuring logging. Your custom UI may provide users with options for adding configurations, rules, and sinks.
In the Services API, the Relativity.Services.LoggingConfig namespace contains the interfaces and other classes required to configure logging. You can use the following interfaces to access the services that support this functionality:
In addition, the Relativity.Services.LoggingConfig namespace contains the following classes used in conjunction with these services:
Use the following guidelines when working with the logging configuration services:
The Logging Configuration Manager service supports creating and deleting logging configurations. It also supports retrieving a list of all configurations currently stored in the EDDSLogging database.
To retrieve a list of available configurations, call the GetAllAsync() method on the ILoggingConfigurationManager interface. This method returns a collection of Configuration objects representing data stored on the EDDSLogging database. For more information, see Fundamentals for logging configuration services.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
public async Task<ICollection<Configuration>> GetAllConfigurationsAsync(Relativity.Services.ServiceProxy.ServiceFactory serviceFactory)
{
ICollection<Configuration> configurations = null;
using (ILoggingConfigurationManager proxy = serviceFactory.CreateProxy<ILoggingConfigurationManager>())
try
{
configurations = await proxy.GetAllAsync();
}
catch (Exception exception)
{
// Optionally, define how to display the error message.
ISampleLogger _logger = Client.SamplesLibrary.Logging.Log.Logger.ForContext<ILoggingConfigurationManager>();
_logger.LogError(exception, "GetAllAsync call for logging configurations failed.");
}
return configurations;
}
You can use the CreateAsync() method on the Logging Configuration Manager service to add a new configuration or update an existing one. To create a new configuration, instantiate a Configuration object with these properties, and pass it as an argument to the CreateAsync() method:
You can specify a combination of the machine, system, subsystem, and application for the collection of logging information.
To update an existing configuration, you must include Id property when instantiating the Configuration object that you pass to the CreateAsync() method. This value is available on the record for the configuration in the EDDSLogging database, or by calling the GetAllAsync() method. The other properties are optional when updating a configuration.
If you don't supply an Id field for an update operation, the service checks for a matching machine, system, subsystem, and application combination in order to make the update. If the service doesn't find a matching combination, then it creates a new configuration.
The following code sample illustrates how to create a new configuration. It includes the required Order property, and other optional properties for a configuration.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
public async Task PostConfigurationAsync(Relativity.Services.ServiceProxy.ServiceFactory serviceFactory)
{
using (ILoggingConfigurationManager proxy = serviceFactory.CreateProxy<ILoggingConfigurationManager>())
try
{
// To update an existing configuration, set the Id property to the Id on an existing Configuration object.
var newConfiguration = new Configuration()
{
Order = 99,
LoggingEnabled = true,
MachineName = "YOUR_MACHINE",
System = "YOUR_AGENT",
SubSystem = "YOUR_SUB",
Application = "YOUR_APPLICATION_GUID"
};
await proxy.CreateAsync(newConfiguration);
}
catch (Exception exception)
{
// Optionally, define how to display the error message.
ISampleLogger _logger = Client.SamplesLibrary.Logging.Log.Logger.ForContext<ILoggingConfigurationManager>();
_logger.LogError(exception, "CreateAsync call for a logging configuration failed.");
}
}
To delete a configuration, use the DeleteAsync() method. You must pass a Configuration object to this method that includes Id property for the configuration that you want removed. Other properties defined on this Configuration object are optional.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
public async Task DeleteConfigurationAsync(Relativity.Services.ServiceProxy.ServiceFactory serviceFactory)
{
using (ILoggingConfigurationManager proxy = serviceFactory.CreateProxy<ILoggingConfigurationManager>())
{
try
{
var configuration = new Configuration()
{
Id = 1026, // rule Id
Order = 99,
LoggingEnabled = true,
MachineName = "YOUR_MACHINE",
System = "YOUR_AGENT",
SubSystem = "YOUR_SUB",
Application = "YOUR_APPLICATION_GUID"
};
await proxy.DeleteAsync(configuration);
}
catch (Exception exception)
{
// Optionally, define how to display the error message.
ISampleLogger _logger = Client.SamplesLibrary.Logging.Log.Logger.ForContext<ILoggingConfigurationManager>();
_logger.LogError(exception, "DeleteAsync call for a logging configuration failed.");
}
}
}
The Logging Rule Manager service supports creating and deleting rules. It also supports retrieving a list of all configurations currently stored in the EDDSLogging database.
To retrieve a list of available rules, call the GetAllAsync() method on the ILoggingRuleManager interface. This method returns a collection of Rule objects representing data stored on the EDDSLogging database. For more information, see Fundamentals for logging configuration services.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
public async Task<ICollection<Rule>> GetAllRulesAsync(Relativity.Services.ServiceProxy.ServiceFactory serviceFactory)
{
ICollection<Rule> rules = null;
using (ILoggingRuleManager proxy = serviceFactory.CreateProxy<ILoggingRuleManager>())
{
try
{
var ruleManager = GetLoggingRuleManager();
rules = await ruleManager.GetAllAsync().Result;
}
catch (Exception exception)
{
// Optionally, define how to display the error message.
ISampleLogger _logger = Client.SamplesLibrary.Logging.Log.Logger.ForContext<ILoggingRuleManager>();
_logger.LogError(exception, "GetAllAsync call for logging rules failed.");
}
}
return rules;
}
You can use the CreateAsync() method on the Logging Rule Manager service to add or update a rule. To create a new rule, instantiate a Rule object with the following properties, and pass it as an argument to this method:
You can specify a combination the machine, system, subsystem, and application for the collection of logging information.
To update an existing rule, you must include Id property when instantiating the Rule object that you pass to the CreateAsync() method. This value is available on the record for the rule in the EDDSLogging database, or by calling the GetAllAsync() method. The other properties are optional when updating a rule.
The following code sample illustrates how to create a rule. It includes the required Order and LoggingLevel properties, and other optional properties for a rule.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
public async Task CreateRuleAsync(Relativity.Services.ServiceProxy.ServiceFactory serviceFactory)
{
using (ILoggingRuleManager proxy = serviceFactory.CreateProxy<ILoggingRuleManager>())
try
{
var newRule = new Rule()
{
Order = 99,
LoggingLevel = "Verbose",
MachineName = "YOUR_MACHINE",
System = "YOUR_AGENT",
SubSystem = "YOUR_SUB",
Application = "YOUR_APPLICATION_GUID"
};
await proxy.CreateAsync(newRule);
}
catch (Exception exception)
{
// Optionally, define how to display the error message.
ISampleLogger _logger = Client.SamplesLibrary.Logging.Log.Logger.ForContext<ILoggingRuleManager>();
_logger.LogError(exception, "CreateAsync call for a logging rule failed.");
}
}
To delete a rule, use the DeleteAsync() method. You must pass a Rule object to this method that includes Id property for the rule that you want removed. Other properties defined on this Rule object are optional.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
public async Task DeleteRuleAsyncTask(Relativity.Services.ServiceProxy.ServiceFactory serviceFactory)
{
using (ILoggingRuleManager proxy = serviceFactory.CreateProxy<ILoggingRuleManager>())
try
{
var rule = new Rule()
{
Id = 1097, // rule Id
Order = 99,
LoggingLevel = "Verbose",
MachineName = "YOUR_MACHINE",
System = "YOUR_AGENT",
SubSystem = "YOUR_SUB",
Application = "YOUR_APPLICATION_GUID"
};
await proxy.DeleteAsync(rule);
}
catch (Exception exception)
{
// Optionally, define how to display the error message.
ISampleLogger _logger = Client.SamplesLibrary.Logging.Log.Logger.ForContext<ILoggingRuleManager>();
_logger.LogError(exception, "DeleteAsync call for a logging rule failed.");
}
}
The Logging Sink Manager service supports creating and retrieving sinks.
To retrieve a list of available sinks, call the GetAllAsync() method on the ILoggingSinkManager interface. This method returns a collection of Sink objects representing data stored on the EDDSLogging database. For more information, see Fundamentals for logging configuration services.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
public async Task<ICollection<Sink>> GetAllSinksAsync(Relativity.Services.ServiceProxy.ServiceFactory serviceFactory)
{
ICollection<Sink> sinks = null;
using (ILoggingSinkManager proxy = serviceFactory.CreateProxy<ILoggingSinkManager>())
{
try
{
sinks = await proxy.GetAllAsync();
}
catch (Exception exception)
{
// Optionally, define how to display the error message.
ISampleLogger _logger = Client.SamplesLibrary.Logging.Log.Logger.ForContext<ILoggingSinkManager>();
_logger.LogError(exception, "GetAllAsync call for logging sinks failed.");
}
}
return sinks;
}
Use the methods on the ILoggingSinkManager interface to create a file, Data Grid, SQL database, or Logentries sink.
To create a file sink, pass the following arguments to the CreateFileSink() method:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
public async Task CreateFileSink(Relativity.Services.ServiceProxy.ServiceFactory serviceFactory)
{
using (ILoggingSinkManager proxy = serviceFactory.CreateProxy<ILoggingSinkManager>())
{
try
{
await proxy.CreateFileSinkAsync("sink Name", "FILE_LOCATION", 22);
}
catch (Exception exception)
{
ISampleLogger _logger = Client.SamplesLibrary.Logging.Log.Logger.ForContext<ILoggingSinkManager>();
_logger.LogError(exception, "CreateFileSinkAsync call for a logging sink failed.");
}
}
}
To create a Data Grid sink, pass the following arguments to the CreateDataGridSinkAsync() method:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
public async Task CreateDataGridSink(Relativity.Services.ServiceProxy.ServiceFactory serviceFactory)
{
using (ILoggingSinkManager proxy = serviceFactory.CreateProxy<ILoggingSinkManager>())
{
try
{
await proxy.CreateDataGridSinkAsync("sink Name", "http://localhost/");
}
catch (Exception exception)
{
ISampleLogger _logger = Client.SamplesLibrary.Logging.Log.Logger.ForContext<ILoggingSinkManager>();
_logger.LogError(exception, "CreateDataGridSinkAsync call for a logging sink failed.");
}
}
}
To create an SQL sink, pass the following arguments to the CreateSqlSinkAsync() method:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
public async Task CreateSqlSink(Relativity.Services.ServiceProxy.ServiceFactory serviceFactory)
{
using (ILoggingSinkManager proxy = serviceFactory.CreateProxy<ILoggingSinkManager>())
{
try
{
await proxy.CreateSqlSinkAsync("sink Name", "connection_string", "table_name");
}
catch (Exception exception)
{
ISampleLogger _logger = Client.SamplesLibrary.Logging.Log.Logger.ForContext<ILoggingSinkManager>();
_logger.LogError(exception, "CreateSqlSinkAsync call for a logging sink failed.");
}
}
}
To create a Logentries sink, pass the following arguments to the CreateLogentriesSinkAsync() method:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
public async Task CreateLogentriesSink(Relativity.Services.ServiceProxy.ServiceFactory serviceFactory)
{
using (ILoggingSinkManager proxy = serviceFactory.CreateProxy<ILoggingConfigurationManager>())
{
try
{
await proxy.CreateLogentriesSinkAsync("sink Name", "token");
}
catch (Exception exception)
{
ISampleLogger _logger = Client.SamplesLibrary.Logging.Log.Logger.ForContext<ILoggingSinkManager>();
_logger.LogError(exception, "CreateLogentriesSinkAsync call for a logging sink failed.");
}
}
}
Why was this not helpful?
Check one that applies.
Thank you for your feedback.
Want to tell us more?
Great!
Additional Resources |
|||
DevHelp Community | GitHub | Release Notes | NuGet |