Skip to content

Logger class in a scheduled job #3567

Answered by sbwalker
pnicosia80 asked this question in Q&A
Discussion options

You must be logged in to vote

@pnicosia80 Oqtane is multi-tenant... so the challenge in a scheduled job is that there is no context... which means that the framework is unable to determine the tenant/site on its own. This is a problem because the LogManager service (and most other Oqtane services) requires this context in order to log information to the database for the appropriate site. So in this scenario you will need to explicitly provide the context:

ie.

// get services
var tenantManager = provider.GetRequiredService<ITenantManager>();
var siteRepository = provider.GetRequiredService<ISiteRepository>();
var logManager = provider.GetRequiredService<ILogManager>();

// get tenant (set by HostedServiceBase)
var tena…

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@pnicosia80
Comment options

@sbwalker
Comment options

@sbwalker
Comment options

@sbwalker
Comment options

@pnicosia80
Comment options

Answer selected by pnicosia80
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants