Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The logging functionality is messed up #15511

Closed
hyzx86 opened this issue Mar 14, 2024 · 9 comments
Closed

The logging functionality is messed up #15511

hyzx86 opened this issue Mar 14, 2024 · 9 comments
Labels
Milestone

Comments

@hyzx86
Copy link
Contributor

hyzx86 commented Mar 14, 2024

I'm looking at logs in the child tenant SalesProtalDev, but it outputs logs for other tenants: |Creating shell context for tenant 'sea2'

2024-03-14 19:09:03.6167|SalesProtalDev|00-0b8c9fce250e53a67da56ccdf9b96010-bd1563b65ec4b0fd-00||OrchardCore.Environment.Shell.ShellHost|DEBUG|Creating shell context for tenant 'sea2' 
2024-03-14 19:09:03.6167|SalesProtalDev|00-0b8c9fce250e53a67da56ccdf9b96010-bd1563b65ec4b0fd-00||OrchardCore.Environment.Shell.Builders.ShellContextFactory|INFO|Creating shell context for tenant 'sea2' 
2024-03-14 19:09:03.6167|SalesProtalDev|00-0b8c9fce250e53a67da56ccdf9b96010-bd1563b65ec4b0fd-00||OrchardCore.Environment.Shell.Builders.ShellContextFactory|DEBUG|Creating described context for tenant 'sea2' 
2024-03-14 19:09:03.6167|SalesProtalDev|00-0b8c9fce250e53a67da56ccdf9b96010-bd1563b65ec4b0fd-00||OrchardCore.Environment.Shell.Builders.CompositionStrategy|DEBUG|Composing blueprint 
2024-03-14 19:09:03.6167|SalesProtalDev|00-0b8c9fce250e53a67da56ccdf9b96010-bd1563b65ec4b0fd-00||OrchardCore.Environment.Shell.Builders.CompositionStrategy|DEBUG|Done composing blueprint 

This is my Nlog.config

<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      autoReload="true"
      internalLogLevel="Warn"
      internalLogFile="${var:configDir}/logs/internal-nlog.txt">

	<extensions>
		<add assembly="NLog.Web.AspNetCore"/>
		<add assembly="OrchardCore.Logging.NLog"/>
	</extensions>

	<targets>
		<!-- file target -->
		<target xsi:type="File" name="file"
                fileName="${var:configDir}/logs/${orchard-tenant-name}/orchard-log-${shortdate}.log"
                layout="${longdate}|${orchard-tenant-name}|${aspnet-traceidentifier}|${event-properties:item=EventId.Id}|${logger}|${uppercase:${level}}|${message} ${exception:format=ToString,StackTrace}"
        />

		<!-- console target --> 
		<target xsi:type="Console" name="console"
			layout="${longdate}|${orchard-tenant-name}|${aspnet-traceidentifier}|${event-properties:item=EventId.Id}|${logger}|${uppercase:${level}}|${message} ${exception:format=ToString,StackTrace}"
/>

	</targets>

	<rules>
		<!-- all warnings and above go to the file target -->
		<!--<logger name="*" minlevel="Warn" writeTo="file" />-->
		<logger name="*" minlevel="Debug" writeTo="file" />

		<!-- the hosting lifetime events go to the console and file targets -->
		<logger name="Microsoft.Hosting.Lifetime" minlevel="Info" writeTo="file, console" />
	</rules>
</nlog>
@Skrypt
Copy link
Contributor

Skrypt commented Mar 14, 2024

It starts with : 2024-03-14 19:09:03.6167|SalesProtalDev
Meaning it is your main tenant. Then the logs says that it created child tenant with shell context named "sea2". I think that's accurate logging.

@hyzx86
Copy link
Contributor Author

hyzx86 commented Mar 14, 2024

orchard-tenant-name : SalesProtalDev

first the file path should like : fileName="${var:configDir}/logs/${orchard-tenant-name}/orchard-log-${shortdate}.log"
The actual file path is : /App_Data/logs/SalesProtalDev/orchard-log-2024-03-14.log

There seems to be no problem here, but you mention that this log actually records that it is creating a tenant context. It should only be output under the default tenant

However, log files under this path should only record context logs for the subtenant (SalesProtalDev).

2024-03-14 19:09:03.6167|SalesProtalDev|00-0b8c9fce250e53a67da56ccdf9b96010-bd1563b65ec4b0fd-00||OrchardCore.Environment.Shell.ShellHost|DEBUG|Creating shell context for tenant 'sea2'

@Skrypt
Copy link
Contributor

Skrypt commented Mar 14, 2024

Ok, now I understand now that you clarified that SalesProtalDev is not the parent tenant that creates these child tenants.
Valid issue. What is "sea2" then?

So guessing here that you have tenants like this:

default
-> SalesProtalDev
-> sea2

@hyzx86
Copy link
Contributor Author

hyzx86 commented Mar 14, 2024

Ok, now I understand now that you clarified that SalesProtalDev is not the parent tenant that creates these child tenants. Valid issue. What is "sea2" then?

So guessing here that you have tenants like this:

default
-> SalesProtalDev
-> sea2

Yes, that's exactly right.

The screenshot below is a screenshot of the environment on my home computer. The log is for the office computer, but the structure is roughly the same

image

@Skrypt
Copy link
Contributor

Skrypt commented Mar 14, 2024

The only thing I can see is that we have a tenant scope issue when these logs gets written.
We should probably take a look at where Creating shell context for tenant 'sea2' is logged and see if we can do it on the main tenant scope.

@Skrypt
Copy link
Contributor

Skrypt commented Mar 14, 2024

And the issue seems to be in ShellContextFactory -> CreateShellContextAsync based on the fact that it logged an INFO instead of a DEBUG.

@hyzx86
Copy link
Contributor Author

hyzx86 commented Mar 14, 2024

This should be a lifecycle assignment issue, as the orchard-tenant-name may be assigned multiple times by different tenants

@sebastienros
Copy link
Member

@ns8482e

@sebastienros sebastienros added this to the 1.9 milestone Mar 14, 2024
@hyzx86
Copy link
Contributor Author

hyzx86 commented Mar 16, 2024

relate #15525

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants