The legal basis is that of physical evidence.
The Fifth Amendment states that you cannot be compelled to testify against yourself.
...nor shall be compelled in any criminal case to be a witness against himself...
But if you write in a journal, you are creating physical evidence, and the fifth amendment does not automatically exclude physical evidence.
The Fourth amendment may be more helpful:
The right of the people to be secure in their persons, houses, papers, and effects, against unreasonable searches and seizures, shall not be violated, and no Warrants shall issue, but upon probable cause, supported by Oath or affirmation, and particularly describing the place to be searched, and the persons or things to be seized.
Legally Obtained, Relevant, and Yours?
In order for the journal to be admissible, it had to be obtained through legal means (i.e. a legal search, as I'm assuming you or your roommate did not voluntarily hand it over). If it was obtained illegally, that may provide grounds for suppression.
Also, in a criminal proceeding, it must be shown that the journal is relevant to the changes you are defending.
For instance, if you are facing a drug dealing charge, and your journal lists your customers and how much they bought — well, that is very relevant.
On the other hand if you are facing a drug charge and the journal only talks about sex with your girlfriend when she was underage, that's not relevant but could lead to an additional investigation or indictment. In that case you'd probably make a motion to suppress as hearsay, or citing that the writings were a fantasy not actualized. (Good luck on that one...)
If you admitted that the journal is yours, and/or that you had exclusive access, it makes any writings contained therein even more probative.
But if you can claim the diary is not yours, and/or that you were not the one writing in it, that could be a way to have it excluded on hearsay grounds.
Without knowing the specifics of the case, it's difficult to suggest other possible actions. But if the diary contains evidence against you, your best hope is challenging it as illegally obtained and/or irrelevant to your charges and/or invalid hearsay and/or a work of fiction for a novel you are writing and hoping to sell to Penguin books.
Once physical evidence is obtained against you, it is up to you to fight it, challenge it, and get it suppressed.
You might find this link useful:
For the record: do not describe criminal behavior in a journal.