Note that the hashcode changes, you need to check the current ClassLoader information first, and extract the hashcode corresponding to the ClassLoader.
if you use`-c`, you have to manually type hashcode by `-c <hashcode>`.
```bash
$ dump -c 3d4eac69 demo.*
```
For classloader with only one instance, it can be specified by `--classLoaderClass` using class name, which is more convenient to use.
* PS: Here the classLoaderClass in java 8 is sun.misc.Launcher$AppClassLoader, while in java 11 it's jdk.internal.loader.ClassLoaders$AppClassLoader. Currently katacoda using java 8.
The value of `--classloaderclass` is the class name of classloader. It can only work when it matches a unique classloader instance. The purpose is to facilitate the input of general commands. However, `-c <hashcode>` is dynamic.
Note that the hashcode changes, you need to check the current ClassLoader information first, and extract the hashcode corresponding to the ClassLoader using `sc -d <ClassName>`.
if you use`-c`, you have to manually type hashcode by `-c <hashcode>`.
```bash
$ getstatic -c 3d4eac69 demo.MathGame random
```
For classloader with only one instance, it can be specified by `--classLoaderClass` using class name, which is more convenient to use.
* PS: Here the classLoaderClass in java 8 is sun.misc.Launcher$AppClassLoader, while in java 11 it's jdk.internal.loader.ClassLoaders$AppClassLoader. Currently katacoda using java 8.
The value of `--classloaderclass` is the class name of classloader. It can only work when it matches a unique classloader instance. The purpose is to facilitate the input of general commands. However, `-c <hashcode>` is dynamic.
Tip: if the static field is a complex class, you can even use [`OGNL`](https://commons.apache.org/proper/commons-ognl/language-guide.html) to traverse, filter and access the inner properties of this class.
|`[c:]`|hashcode of the class loader that loads the class|
|`[classLoaderClass:]`| The class name of the ClassLoader that executes the expression. |
|`[E]`|turn on regex match while the default is wildcard match|
### Usage
@ -143,3 +144,7 @@ public class Logger extends Category
Affect(row-cnt:1) cost in 190 ms.
```
For classloader with only one instance, it can be specified by `--classLoaderClass` using class name, which is more convenient to use.
The value of `--classloaderclass` is the class name of classloader. It can only work when it matches a unique classloader instance. The purpose is to facilitate the input of general commands. However, `-c <hashcode>` is dynamic.
By default,logger command will be executed under SystemClassloader, if the application is a traditional `war`, or using spring boot fat jar, then it needs to specify classloader。
<tdalign="left">The class name of the ClassLoader that executes the expression.</td>
</tr>
<tr>
<tdalign="right"><code>[d:]</code></td>
<tdalign="left">set the destination directory for class files</td>
</tr>
@ -274,6 +278,24 @@ Affect(row-cnt:1) cost in 39 ms.</pre></div>
null /tmp/output/java/lang/String.class
Affect(row-cnt:1) cost in 138 ms.</pre></div>
</div>
<ulclass="simple">
<li><p>Specify classLoader</p></li>
</ul>
<p>Note that the hashcode changes, you need to check the current ClassLoader information first, and extract the hashcode corresponding to the ClassLoader.</p>
<p>if you use<codeclass="docutils literal notranslate"><spanclass="pre">-c</span></code>, you have to manually type hashcode by <codeclass="docutils literal notranslate"><spanclass="pre">-c</span><spanclass="pre"><hashcode></span></code>.</p>
<p>For classloader with only one instance, it can be specified by <codeclass="docutils literal notranslate"><spanclass="pre">--classLoaderClass</span></code> using class name, which is more convenient to use.</p>
<li><p>PS: Here the classLoaderClass in java 8 is sun.misc.Launcher$AppClassLoader, while in java 11 it’s jdk.internal.loader.ClassLoaders$AppClassLoader. Currently katacoda using java 8.</p></li>
</ul>
<p>The value of <codeclass="docutils literal notranslate"><spanclass="pre">--classloaderclass</span></code> is the class name of classloader. It can only work when it matches a unique classloader instance. The purpose is to facilitate the input of general commands. However, <codeclass="docutils literal notranslate"><spanclass="pre">-c</span><spanclass="pre"><hashcode></span></code> is dynamic.</p>
<p>Note that the hashcode changes, you need to check the current ClassLoader information first, and extract the hashcode corresponding to the ClassLoader using <codeclass="docutils literal notranslate"><spanclass="pre">sc</span><spanclass="pre">-d</span><spanclass="pre"><ClassName></span></code>.</p>
<p>if you use<codeclass="docutils literal notranslate"><spanclass="pre">-c</span></code>, you have to manually type hashcode by <codeclass="docutils literal notranslate"><spanclass="pre">-c</span><spanclass="pre"><hashcode></span></code>.</p>
<p>For classloader with only one instance, it can be specified by <codeclass="docutils literal notranslate"><spanclass="pre">--classLoaderClass</span></code> using class name, which is more convenient to use.</p>
<li><p>PS: Here the classLoaderClass in java 8 is sun.misc.Launcher$AppClassLoader, while in java 11 it’s jdk.internal.loader.ClassLoaders$AppClassLoader. Currently katacoda using java 8.</p></li>
</ul>
<p>The value of <codeclass="docutils literal notranslate"><spanclass="pre">--classloaderclass</span></code> is the class name of classloader. It can only work when it matches a unique classloader instance. The purpose is to facilitate the input of general commands. However, <codeclass="docutils literal notranslate"><spanclass="pre">-c</span><spanclass="pre"><hashcode></span></code> is dynamic.</p>
<p>Tip: if the static field is a complex class, you can even use <aclass="reference external"href="https://commons.apache.org/proper/commons-ognl/language-guide.html"><codeclass="docutils literal notranslate"><spanclass="pre">OGNL</span></code></a> to traverse, filter and access the inner properties of this class.</p>
<tdalign="left">The class name of the ClassLoader that executes the expression.</td>
</tr>
<tr>
<tdalign="right"><code>[E]</code></td>
<tdalign="left">turn on regex match while the default is wildcard match</td>
</tr>
@ -383,6 +387,8 @@ public class Logger extends Category
Affect(row-cnt:1) cost in 190 ms.</pre></div>
</div>
<p>For classloader with only one instance, it can be specified by <codeclass="docutils literal notranslate"><spanclass="pre">--classLoaderClass</span></code> using class name, which is more convenient to use.</p>
<p>The value of <codeclass="docutils literal notranslate"><spanclass="pre">--classloaderclass</span></code> is the class name of classloader. It can only work when it matches a unique classloader instance. The purpose is to facilitate the input of general commands. However, <codeclass="docutils literal notranslate"><spanclass="pre">-c</span><spanclass="pre"><hashcode></span></code> is dynamic.</p>
<liclass="toctree-l4"><aclass="reference internal"href="#view-logger-information-for-the-special-name">View logger information for the special name</a></li>
<liclass="toctree-l4"><aclass="reference internal"href="#view-logger-information-for-the-special-classloader">View logger information for the special classloader</a></li>
<liclass="toctree-l4"><aclass="reference internal"href="#speecify-classloader-to-update-logger-level">Speecify classloader to update logger level</a></li>
<liclass="toctree-l4"><aclass="reference internal"href="#view-the-logger-information-without-appenders">View the logger information without appenders</a></li>
</ul>
</li>
@ -361,10 +361,10 @@
update logger level success.</pre></div>
</div>
</div>
<divclass="section"id="classloader-logger-level">
<h3>指定classloader更新 logger level<aclass="headerlink"href="#classloader-logger-level" title="Permalink to this headline">¶</a></h3>
<h3>Speecify classloader to update logger level<aclass="headerlink"href="#speecify-classloader-to-update-logger-level" title="Permalink to this headline">¶</a></h3>
<p>By default,logger command will be executed under SystemClassloader, if the application is a traditional <codeclass="docutils literal notranslate"><spanclass="pre">war</span></code>, or using spring boot fat jar, then it needs to specify classloader。</p>
<p>You can first use<codeclass="docutils literal notranslate"><spanclass="pre">sc</span><spanclass="pre">-d</span><spanclass="pre">yourClassName</span></code>to check specified classloader hashcode,then specify classloader when updating logger level:</p>
<p>You can also specify the ClassLoader with the <codeclass="docutils literal notranslate"><spanclass="pre">--classLoaderClass</span></code> option:</p>
<divclass="highlight-bash notranslate"><divclass="highlight hljs"><preclass="bash">$ mc --classLoaderClass org.springframework.boot.loader.LaunchedURLClassLoader /tmp/UserController.java -d /tmp