I have an application which redirect `System.out` for example;

```
  System.setOut(new PrintStream(System.out){
    @Override
    public void print(String string)
    {
      //TODO: find out who sent the print before processing string
    }
  });

```

I want to be able to determine which class is sending the call to print to stdout? I think this is not possible, but cannot fully conclude unless `SO` say so.
['https://Stackoverflow.com/questions/12195583', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/340390/']
You could throw an exception, and examine the stack trace. Obviously not great for production code.
There are a number of ways: SecurityManager might be the best. Check this post especially the second answer: [How do I find the caller of a method using stacktrace or reflection?](https://stackoverflow.com/questions/421280/in-java-how-do-i-find-the-caller-of-a-method-using-stacktrace-or-reflection)