You have a number of options:
Specify the location of the log4j configuration file on the file system. The path in a file: URL must be absolute. On Windows, file: URLs start with either "file:/", or "file:///", and '/' characters replace '\' characters in the path. Your line would be:
export JAVA_OPTS=-Dlog4j.configurationFile=file:/path/to/your/log4j2.xml
Specify the location of the log4j configuration file relative to a classpath entry. If the "/path/to/your/" directory is on the classpath your line would be:
export JAVA_OPTS=-Dlog4j.configurationFile=log4j2.xml
Specify the location of log4J configuration file to be used for all JVMs. Your line would be:
export _JAVA_OPTIONS=-Dlog4j.configurationFile=file:/path/to/your/log4j2.xml
Specify the location of the log4j configuration file on the Java command line for your application. Your line would be:
-Dlog4j.configurationFile=file:/path/to/your/log4j2.xml
In your question, you don't specify what application you are running, but these options will all work.
If you are trying to specify the log4j configuration to use in an application running on a JEE container, e.g. a web application, please refer to the log4j documentation.
I hope this helps you out.