> For the complete documentation index, see [llms.txt](https://docs.snyk.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.snyk.io/developer-tools/snyk-cli/scan-and-maintain-projects-using-the-cli/log4shell-command-use.md).

# Log4shell command use

How to use the snyk log4shell command to scan for the Log4Shell vulnerability

## Introduction

`snyk log4shell` is a Snyk CLI command, that helps find traces of the **log4j** library that are affected by the **Log4Shell** vulnerability ([CVE-2021-44228](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-44228)), even if this library is not declared in the manifest files (such as pom.xml or build.gradle).

This command tests your built project and third-party applications, and it is complementary to the `snyk test` and `snyk test --scan-all-unmanaged` commands.

{% hint style="info" %}
Read more about the Log4Shell vulnerability in the Snyk [VulnDB entry](https://security.snyk.io/vuln/SNYK-JAVA-ORGAPACHELOGGINGLOG4J-2314720).
{% endhint %}

To test Java projects using their package manager manifest files, see [Options for Maven projects](/developer-tools/snyk-cli/commands/test.md#options-for-maven-projects) and [Options for Gradle projects](/developer-tools/snyk-cli/commands/test.md#options-for-gradle-projects) in the CLI `test` command help.

To learn more about the `snyk test --scan-all-unmanaged`, see the [Maven options section of the CLI reference](/developer-tools/snyk-cli/cli-commands-and-options-summary.md#option-for-maven-projects).

## Usage

Use `snyk log4shell` to scan a Java project, to see if the project includes:

* Any `.jar` or `.war` files with a vulnerable version of log4j.
* Any files that are known to be present in a vulnerable version of the log4j library. Such a finding indicates that it is possible the whole log4j is included.

## How to run

1. Install the latest version of the Snyk CLI - see [Install the Snyk CLI](/developer-tools/snyk-cli/install-the-snyk-cli.md).
2. Make sure you have built the project.
3. Navigate to the project directory to scan.
4. Enter `snyk log4shell`.\
   **Note**: this command does not require (nor support) any additional arguments.

## Scan results

Results appear after the scan finishes.

For example:

```bash
$ snyk log4shell
Please note this command is for already built artifacts. To test source code use `snyk test`.

Results:
A vulnerable version of log4j was detected: 
         demo-0.0.1-SNAPSHOT/WEB-INF/lib/log4j-core-2.14.1.jar
         demo-0.0.1-SNAPSHOT.war/WEB-INF/lib/log4j-core-2.14.1.jar
         demo-0.0.1-SNAPSHOT.war.original/WEB-INF/lib/log4j-core-2.14.1.jar

 We highly recommend fixing this vulnerability. If it cannot be fixed by upgrading, see mitigation information here:
        - https://security.snyk.io/vuln/SNYK-JAVA-ORGAPACHELOGGINGLOG4J-2314720
        - https://snyk.io/blog/log4shell-remediation-cheat-sheet/
```

If no traces of a vulnerable log4j library are found, the results show this:

```
$ snyk log4shell
Please note this command is for already built artifacts. To test source code use `snyk test`.

Results:
No known vulnerable version of log4j was detected
```

## Fix advice

For more details about fixing the affected packages, see the Snyk [Log4Shell fix cheatsheet](https://snyk.io/blog/log4shell-remediation-cheat-sheet).

## Limitations

* The Snyk CLI compares file signatures to a database of known files. If the Log4Shell vulnerability is fixed in a different way from updating the log4j library, the library is still reported in the results.
* If the source code of the log4j library has been modified, it is detected.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.snyk.io/developer-tools/snyk-cli/scan-and-maintain-projects-using-the-cli/log4shell-command-use.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
